| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ActiveDirectoryMembershipProvider Class.NET Framework version 2.0 Manages storage of membership information for an ASP.NET application in Active Directory and Active Directory Application Mode servers.
RemarksThis class is used by the Membership and MembershipUser classes to provide membership services for an ASP.NET application using an Active Directory ( AD ) or Active Directory Application Mode ( ADAM ) server.
The ActiveDirectoryMembershipProvider class requires unrestricted DirectoryServicesPermission permission to run. This permission is not added to any of the partial-trust policy files supplied with ASP.NET. Although adding the DirectoryServicesPermission permission to a partial-trust policy file will enable use of the ActiveDirectoryMembershipProvider class, doing so makes the System.DirectoryServices namespace classes available to any code running in your ASP.NET pages. This option is not recommended for any Web servers that need to run in a secure, locked-down mode. As an alternative, you can create a "sandbox" assembly that calls the ActiveDirectoryMembershipProvider class. This assembly can contain either a wrapper class that forwards method calls to the ActiveDirectoryMembershipProvider class or a class that derives from the ActiveDirectoryMembershipProvider class. In either case, the wrapper class must assert unrestricted DirectoryServicesPermission permission. Deploy the sandbox assembly in the GAC and mark the assembly with the AllowPartiallyTrustedCallersAttribute ( APTCA ) attribute. This will enable your partially trusted ASP.NET code to call your wrapper class, and since the wrapper class internally asserts the unrestricted DirectoryServicesPermission permission, your wrapper class will be able to successfully call the provider. You must create a connectionStrings entry in the Web.config file that identifies the Active Directory server, Active Directory domain, or ADAM application partition to use. The provider will only operate at domain scope, or in a subscope within a domain. The following table lists allowed connection strings and the scope used.
The ActiveDirectoryMembershipProvider instance maps directory attributes to ActiveDirectoryMembershipUser properties. Default attributes are used if no attribute mapping is done in the Web.config file. For more information on attribute mappings, see the individual properties in the ActiveDirectoryMembershipUser class documentation. The following table lists the ActiveDirectoryMembershipUser properties and their default attribute mappings.
When both the RequiresQuestionAndAnswer and EnablePasswordReset properties are true, the ActiveDirectoryMembershipProvider class supports password-reset security by requiring the user to answer a predetermined question. To support the question and answer, you must set the following configuration attributes using the add Element for providers in the application configuration file.
For more information on using password-reset security, see the RequiresQuestionAndAnswer property. Active Directory connectionsWhen the ActiveDirectoryMembershipProvider class is used to connect to an Active Directory or an Active Directory Application Mode ( ADAM ) server, the connectionProtection attribute that is set using the add Element for providers in the application configuration file may restrict the types of operations the ActiveDirectoryMembershipProvider class can perform over the connection. The connectionProtection attribute also determines the methods the ActiveDirectoryMembershipProvider instance will use to create the connection to the Active Directory or ADAM server. The following table shows the effect of the connectionProtection attribute when connecting to an Active Directory.
The following table shows the effect of the connectionProtection attribute when connecting to an ADAM server.
ADAM ConfigurationWhen using an ADAM server, the ADAM instance must contain a schema that defines the User class. You can import the User class with an LDIF import of the The ActiveDirectoryMembershipProvider class will work with an ADAM server configured to use the default network ports. The following table shows the defaults expected for the ADAM server.
If your ADAM server is not using the default ports, see Active Directory Services does not request secure authorization over an SSL connection in the Microsoft Knowledge Base. ExampleThe following code examples show the Web.config file for an ASP.NET application configured to use an ActiveDirectoryMembershipProvider instance. The first example uses the default mappings for Active Directory attributes, and does not support password-reset security with question-and-answer nor the ability to call search methods. The second example shows all the attribute settings allowed for an ActiveDirectoryMembershipProvider instance. The first example is a simple configuration file using default mappings for Active Directory attributes. <configuration>
<connectionStrings>
<add name = "ADService"
connectionString = "LDAP://ldapServer/" />
</connectionStrings>
<system.web>
<membership defaultProvider = "AspNetActiveDirectoryMembershipProvider">
<providers>
<add name = "AspNetActiveDirectoryMembershipProvider"
type = "System.Web.Security.ActiveDirectoryMembershipProvider,
System.Web, Version=2.0.3600, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
</system.web>
</configuration>
This example shows all the attribute settings available for an ActiveDirectoryMembershipProvider instance. <configuration>
<connectionStrings>
<add name = "ADService" connectionString = "LDAP://ldapServer/" />
</connectionStrings>
<system.web>
<membership
defaultProvider = "AspNetActiveDirectoryMembershipProvider">
<providers>
<add name = "AspNetActiveDirectoryMembershipProvider"
type = "System.Web.Security.ActiveDirectoryMembershipProvider,
System.Web, Version=1.0.3600, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName = "ADService"
connectionUserName = "UserWithAppropriateRights"
connectionPassword = "PasswordForUser"
connectionProtection = "Secure"
enablePasswordReset = "true"
enableSearchMethods = "true"
requiresQuestionAndAnswer = "true"
applicationName = "/"
description = "Default AD connection"
requiresUniqueEmail = "false"
clientSearchTimeout = "30"
serverSearchTimeout = "30"
attributeMapPasswordQuestion = "department"
attributeMapPasswordAnswer = "division"
attributeMapFailedPasswordAnswerCount = "singleIntAttribute"
attributeMapFailedPasswordAnswerTime = "singleLargeIntAttribute"
attributeMapFailedPassswordAnswerLockoutTime = "singleLargeIntAttribute"
maxInvalidPasswordAttemps = "5"
passwordAttemptWindow = "10"
passwordAnswerAttemptLockoutDuration = "30"
minRequiredPasswordLength = "7"
minRequiredNonalphanumericCharacters = "1"
passwordStrengthRegularExpression = "
@\"(?=.{6,})(?=(.*\d){1,})(?=(.*\W){1,})" />
/>
</providers>
</membership>
</system.web>
</configuration>
See AlsoActiveDirectoryMembershipUser Class |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme