diff --git a/docs/manual/src/docbook/ldap-auth-provider.xml b/docs/manual/src/docbook/ldap-auth-provider.xml
index 46821a70aa..e77a0f88fb 100644
--- a/docs/manual/src/docbook/ldap-auth-provider.xml
+++ b/docs/manual/src/docbook/ldap-auth-provider.xml
@@ -223,13 +223,6 @@
The class PasswordComparisonAuthenticator implements
the password comparison authentication strategy.
-
-
- Active Directory Authentication
-
- In addition to standard LDAP authentication (binding with a DN), Active
- Directory has its own non-standard syntax for user authentication.
-
@@ -376,4 +369,55 @@ public interface UserDetailsContextMapper {
to locate the user, this will be the data returned by the search object).
+
+ Active Directory Authentication
+ Active Directory supports its own non-standard authentication options, and the normal usage pattern
+ doesn't fit too cleanly with the standard LdapAuthenticationProvider.
+ Typically authentication is performed using the domain username (in the form user@domain),
+ rather than using an LDAP distinguished name. To make this easier, Spring Security 3.1 has an
+ authentication provider which is customized for a typical Active Directory setup.
+
+
+ ActiveDirectoryLdapAuthenticationProvider
+ Configuring ActiveDirectoryLdapAuthenticationProvider is
+ quite straightforward. You just need to supply the domain name and an LDAP URL
+ supplying the address of the server
+ It is also possible to obtain the server's IP address using a DNS lookup. This
+ is not currently supported, but hopefully will be in a future version.
+ . An example configuration would then look like this:
+
+
+
+}]]>
+ Note that there is no need to specify a separate
+ ContextSource in order to define the server location - the bean
+ is completely self-contained. A user named Sharon
, for example, would
+ then be able to authenticate by entering either the username
+ sharon or the full Active Directory
+ userPrincipalName, namely sharon@mydomain.com.
+ The user's directory entry will then be located, and the attributes returned for
+ possible use in customizing the created UserDetails
+ object (a UserDetailsContextMapper can be injected
+ for this purpose, as described above). All interaction with the directory takes
+ place with the identity of the user themselves. There is no concept of a
+ manager
user.
+ By default, the user authorities are obtained from the memberOf
+ attribute values of the user entry. The authorities allocated to the user can again
+ be customized using a UserDetailsContextMapper. You
+ can also inject a GrantedAuthoritiesMaper into the
+ provider instance to control the authorities which end up in the
+ Authentication object.
+
+ Active Directory Error Codes
+ By default, a failed result will cause a standard Spring Security
+ BadCredentialsException. If you set the property
+ convertSubErrorCodesToExceptions to true,
+ the exception messages will be parsed to attempt to extract the Active
+ Directory-specific error code and raise a more specific exception. Check the
+ class Javadoc for more information.
+
+
+
diff --git a/ldap/src/main/java/org/springframework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProvider.java b/ldap/src/main/java/org/springframework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProvider.java
index 3094d4ad98..054d7cb8cb 100644
--- a/ldap/src/main/java/org/springframework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProvider.java
+++ b/ldap/src/main/java/org/springframework/security/ldap/authentication/ad/ActiveDirectoryLdapAuthenticationProvider.java
@@ -96,9 +96,10 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends AbstractLda
* @param url an LDAP url (or multiple URLs)
*/
public ActiveDirectoryLdapAuthenticationProvider(String domain, String url) {
- Assert.isTrue(StringUtils.hasText(domain) || StringUtils.hasText(url), "Domain and url cannot both be empty");
+ Assert.isTrue(StringUtils.hasText(url), "Url cannot be empty");
this.domain = StringUtils.hasText(domain) ? domain.toLowerCase() : null;
- this.url = StringUtils.hasText(url) ? url : null;
+ //this.url = StringUtils.hasText(url) ? url : null;
+ this.url = url;
rootDn = this.domain == null ? null : rootDnFromDomain(this.domain);
}