How do I use Forms Authentication with Active Directory?

Use the built-in ActiveDirectoryMembershipProvider. Use the new login controls to create a forms authentication login page.
To use forms authentication with an Active Directory user store:

1.Configure your application for Forms Authentication in the Web.Config file as follows
<authentication mode=”Forms”>

2.Configure your application to deny access to unauthenticated users in the Web.config file as follows:
<authorization>
<deny users=”?”/>
</authorization>
3.Configure an LDAP connection string in the connectionStrings section of Web.config to point to the Active Directory to be used.
<connectionStrings>
<add name=”ADConnectionString”
connectionString=”LDAP://testdomain.test.com/CN=Users,
DC=testdomain,DC=test,DC=com” />
</connectionStrings>
4.Configure the ActiveDirectoryMembershipProvider in the Web.config file specifying at least the connection string name and optionally the credentials (using connectionUserName and connectionPassword attributes) of an account with permissions to access Active Directory.
Ensure that the defaultProvider attribute is set to the provider configured.
<membership defaultProvider=”MyADMembershipProvider”>
<providers>
<add name=”MyADMembershipProvider”
type=”System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”
connectionStringName=”ADConnectionString”
connectionUsername=”testdomain\administrator”
connectionPassword=”password”/>
</providers>
</membership>

Posted by Mahesh ( Tryangled )

Leave a Reply

You must be logged in to post a comment.