Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

public final class ActiveDirectoryLdapAuthenticationProvider

  1. Object
  2. ActiveDirectoryLdapAuthenticationProvider

ImplementsAuthenticationProvider

Signs users in against Active Directory, as Spring’s provider of the same name: binds as user@domain, reads the user’s entry by userPrincipalName, and makes each group in memberOf an authority named by the group’s CN (Domain Admins, no prefix).

A refused bind is told apart by Active Directory’s sub-error code: a locked account is a LockedException, an expired password a CredentialsExpiredException, a disabled account a DisabledException, an expired account an AccountExpiredException; the rest is a BadCredentialsException.

http.authenticationProvider(new ActiveDirectoryLdapAuthenticationProvider(
        "corp.example", "ldaps://dc1.corp.example"));

Constructors

public ActiveDirectoryLdapAuthenticationProvider(String domain, String url)
public ActiveDirectoryLdapAuthenticationProvider(String domain, String url, String rootDn)

Methods

public LdapContextSource getContextSource()The context source, for its timeouts and TLS settings.
public void setSearchFilter(String searchFilter)The user filter; {0} is user@domain, {1} the name as typed.
public void setSearchNestedGroups(boolean nestedGroups)Whether a user’s authorities include the groups their groups are in.
public Authentication authenticate(Authentication authentication)The accepted authentication, or null when this provider cannot decide and the next one should be asked.
public boolean supports(Class<?> authentication)Whether this provider checks tokens of this class.

Inherited methods

Constructor details

ActiveDirectoryLdapAuthenticationProvider

public ActiveDirectoryLdapAuthenticationProvider(String domain, String url)

ActiveDirectoryLdapAuthenticationProvider

public ActiveDirectoryLdapAuthenticationProvider(String domain, String url, String rootDn)

Parameters

domain String
Not documented.
url String
Not documented.
rootDn String
where users are searched; null for the domain’s root (corp.example is dc=corp,dc=example)

Method details

getContextSource

public LdapContextSource getContextSource()
The context source, for its timeouts and TLS settings.

setSearchFilter

public void setSearchFilter(String searchFilter)
The user filter; {0} is user@domain, {1} the name as typed.

setSearchNestedGroups

public void setSearchNestedGroups(boolean nestedGroups)
Whether a user’s authorities include the groups their groups are in. Active Directory’s memberOf lists direct groups only; with this on, one more search asks the directory for every group that contains the user through any chain (LDAP_MATCHING_RULE_IN_CHAIN). Off by default, as in Spring, since on a large forest that search is not cheap.

authenticate

public Authentication authenticate(Authentication authentication)
The accepted authentication, or null when this provider cannot decide and the next one should be asked.

Throws

AuthenticationException
when the token is refused

supports

public boolean supports(Class<?> authentication)
Whether this provider checks tokens of this class.