Both the Active Directory and the SQL Server Membership Providers support the “Enable Password Reset” and “Requires Answers and Questions” Security options. This is not very difficult to enable but it does require few steps to get this working.
There are four main steps that are required:
- Enable Password Question and Password Reset
- Mapping Password Question and Answer Attributes
- Modify the Schema
- Configure non-autogenerated machine key
Enable Password Question and Password Reset:
When these attributes are set to true in the web config file as seen below, the user is required to provide an answer to a Password Question when the password is first created. When the user resets their password, they will also be required to provider the answer they supplied to the Password Question when the password was first created.
Mapping Password Question and Answer Attributes:
Both the Password Question and the Answer will be saved in the SQL Server, Active Directory, or the Active Directory Application Mode (ADAM) depending upon the provider you are using. However, if you are using the Active Directory Provider you will be required to modify the schema of either the Active Directory or ADAM to store the Password Question and Password Answer. Then in the web config file you will need map the Password Question and Answer’s attributes to the modified schema as shown below:
Example Schema Modification:
Creating the PwdQuestion and PwdAnswer attribute as defined above is not difficult in the ADAM ADSI Edit tool under the Schema configuration, but initially it takes a while to figure out what values required by the attribute schema wizard. Below is an example of the values that you can use in your Active Directory or ADAM directory.
OMSyntax: 64 (for Unicode string)
AttributeSyntax: 22.214.171.124 (Active Directory syntax type of Unicode)
AttributeID: 1.2.840.1135126.96.36.199.1.6221 (Unique Object Identifiers (OIDs))
OMSyntax: 64 (for Unicode string)
For definition on the Attributes value the following URL provide a good reference:
Configure non-autogenerated Machine Key:
Once you configure everything as above you will, however, receive the following error: “You must specify a non-autogenerated machine key to store passwords in the encrypted format. Either specify a different passwordFormat, or change the machineKey configuration to use a non-autogenerated decryption key”.
The reason behind this is answer is stored in encrypted form within the directory. Otherwise, if the provider stored it in clear text anyone with read rights to the attribute would effectively be able to steal a person's password. The encryption uses the encryption key stored in <machineKey />. Since autogenerated machine keys are non-portable across machines, the provider requires you to explicitly specify the decryption key.
Therefore, you will need to configure the Machine Key to explicitly specify the decryption key. The new explicitly machine key can be modified in the machine config file or if you want the key to only apply to the your ASP.Net 2.0 application specify the value in the application web config file as show below:
More information on the Machine Key in ASP.NET 2.0 can be found at the following URL:
Or visit this nifty site to have a machine key generated for you:
You are now ready to use the Password Question and Password Reset Security options with ADAM.
In an upcoming blog I will discuss how to enable other advance password features such as Password Lockout based upon a number of invalid password attempts.