What Is Active Directory
An active directory is a directory structure used on Microsoft Windows based computers and servers to store information and data about networks and domains.
To use Active Directory (AD) in ASP.Net, First we have to create “Instance For ADAM” and configuration of it. Then I will create a sample application and explain how to interact ADAM with ASP.Net.
Creating Instance and Configuration:
Install ADAM software. Then select “Create an ADAM Instance” in the start menu.
Select “A Unique Instance”, then give some name to the Instance
Give a Port number, leave default SSL port number.
Select “Yes, to create an application directory partition”.
Here O,DC are the LDAP attributes.
Leave default values for location of data file and backup file.
Provide the account under which this account runs.
It will prompt for confirmation,select “YES”. Then select System
Import all LDIF Files.
Copy contents and paste in a file(notepad, etc)
Click Next which will Instantiate new Instance.
Click Finish. And open ADAM ADSI Edit in start menu.
Right click on ADSI root node and click connect to. And enter the details as.
Right click on Distinguished name and select New -> Object in that one select “Organizational Unit” which for Admin.
Click on Finish. Now right click on the Organizational Unit which is created and select Properties, in that properties select distinguished name property and copy into a notepad.
Right click on new OU(Organizational Unit) and create a new User
Now right click on CN=TestAdminUser and select properties, in that properties change the User Principal Name as
And make the “Don’tExpirePassword” property to false.
Now right click on TestAdminUser and reset the password.
Go to CN=Roles and choose CN=Administrators and choose properties and go to member property.
Click on Add ADAM Account and add the user created above.
Create another Organizational Unit (OU) for the user to create login account programmatically.
Go to Roles and choose CN=Readers and choose properties and then select “member” property. Add ADAM account.
Now open ADAM command prompt and run command “dsmgmt.exe”
Now configure ADAM schema – Password policy setting. Type as “mmc /a”.
Click on File – Add/Remove snap – In and then click on ADD and select ADAM Schema
Select ok, ok. Right Click on ADAM Schema and change the server details. Enter the details of ADAM Instance.
Right click on Attributes and click on create attribute.
Go to Classes Node in the Adam Schema, select User and right click and choose properties and select Attributes tab.
Add all the properties created above.
Go to ADAM ADSI Edit , select the instance and right click on it. In that select Update Schema Now.
Note:I created a document of "ADAM Instance Creation" with all of screen shots. You can find below.
Interacting with ADAM with ASP.Net
Step 1: Create a website and add three pages to the application with name Registration.aspx, Login.aspx, Welcome.aspx.
Step 2: Open Registration.aspx page. Drag “CreateUserWizard” control and set the “ContinueDestinationPageUrl” as “~/login.aspx”.
Step 3: Now open login.aspx page. Drag “Login” control and set the “DestinationPageUrl” property to welcome.aspx. and set “DisplayRememberMe” to false.
Step 4: Now open the web.config file and add the blow mentioned code.
Once you modified web.config as like above. Then run the registration page and create a User. If user created succesfully you can find a file created with user name in "TestUsers" section of ADAM.
Note:Add "System.DirectoryServices" assembly reference to your application.
Download creating ADAM Instance Step by step Document.
Download Sample Application