Authenticate Against The AD Using Forms Authentication and VBNet
Authenticate Against The AD Using Forms Authentication and VBNet
Page 1 of 4
Windows
Internet Explorer
Office
Surface
Xbox
Skype
Windows Phone
More products
How to authenticate against the Active Directory by using forms authentication and Visual Basic .NET
Article ID: 326340 - View products that this article applies to.
SUMMARY
This step-by-step article describes how an ASP.NET application can use Forms authentication to permit users to authenticate against the Active Directory by using the Lightweight Directory Access Protocol (LDAP). After the user is authenticated and redirected, you can use the Application_AuthenticateRequest method of the Global.asax file to store a GenericPrincipal object in the HttpContext.User property that flows throughout the request.
http://support.microsoft.com/default.aspx?scid=kb;en-us;326340
4/26/2013
How to authenticate against the Active Directory by using forms authentication and Visua... Page 2 of 4
format. The DirectoryEntry object then tries to force the AdsObject binding by obtaining the NativeObject property. If this succeeds, the CN attribute for the user is obtained by creating a DirectorySearcher object and by filtering on the SAMAccountName. After the user is authenticated, the IsAuthenticated method returns true. Note When you use LDAP to bind to an Active Directory-related object, TCP ports are being used. Increased use of LDAP with the System.DirectoryServices namespace may use all the TCP ports that are available. You may be able to reduce the TCP load by reusing the connection that you used to authenticate your user. User Groups To obtain a list of groups that the user belongs to, this code calls the LdapAuthentication.GetGroups method. The LdapAuthentication.GetGroups method obtains a list of security and distribution groups that the user belongs to by creating a DirectorySearcher object and by filtering according to the memberOf attribute. This method returns a list of groups that is separated by pipes (|). Notice that the LdapAuthentication.GetGroups method manipulates and truncates strings. This reduces the length of the string that is stored in the authentication cookie. If the string is not truncated, the format of each group appears as follows: CN=...,...,DC=domain,DC=com This can create a very long string. If the length of this string is greater than the length of the cookie, the authentication cookie may not be created. If this string may potentially be greater than the length of the cookie, you may want to store the group information in the ASP.NET Cache object or in a database. Alternatively, you may want to encrypt the group information and store this information in a hidden form field.
The default IUSR_computername account does not have permission to the Active Directory.
http://support.microsoft.com/default.aspx?scid=kb;en-us;326340
4/26/2013
How to authenticate against the Active Directory by using forms authentication and Visua... Page 3 of 4
REFERENCES
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base: 306590 (http://support.microsoft.com/kb/306590/ ) ASP.NET security overview 317012 (http://support.microsoft.com/kb/317012/ ) Process and request identity in ASP.NET 306238 (http://support.microsoft.com/kb/306238/ ) How to implement role-based security with forms-based authentication in your ASP.NET application by using Visual Basic .NET 313091 (http://support.microsoft.com/kb/313091/ ) How to create keys by using Visual Basic .NET for use in Forms authentication
http://support.microsoft.com/default.aspx?scid=kb;en-us;326340
4/26/2013
How to authenticate against the Active Directory by using forms authentication and Visua... Page 4 of 4
313116 (http://support.microsoft.com/kb/313116/ ) Forms authentication requests are not directed to loginUrl page
Properties
Article ID: 326340 - Last Review: March 22, 2007 - Revision: 4.5 APPLIES TO
Microsoft ASP.NET 1.0 Microsoft Visual Basic .NET 2002 Standard Edition Microsoft ASP.NET 1.1 Microsoft Visual Basic .NET 2003 Standard Edition
Give Feedback
Back to the top
http://support.microsoft.com/default.aspx?scid=kb;en-us;326340
4/26/2013