Class LdapManager


  • public class LdapManager
    extends java.lang.Object
    Manager for all LDAP related processing.
    Since:
    jcms-9.0.1
    • Field Detail

      • PERIODIC_SYNC_ENABLED

        public static final java.lang.String PERIODIC_SYNC_ENABLED
        See Also:
        Constant Field Values
      • PERIODIC_SYNC_SCHEDULE

        public static final java.lang.String PERIODIC_SYNC_SCHEDULE
        See Also:
        Constant Field Values
      • SYNCHRONIZE_CREATE_DBMEMBER_PROP

        public static final java.lang.String SYNCHRONIZE_CREATE_DBMEMBER_PROP
        See Also:
        Constant Field Values
      • PERIODIC_SYNC_MAX_OP_PER_SYNC_PROP

        public static final java.lang.String PERIODIC_SYNC_MAX_OP_PER_SYNC_PROP
        Property name used to specify the maximum number of operations to process per periodical sync.
        Since:
        10.0.8 / JCMS-10654
        See Also:
        Constant Field Values
      • PERIODIC_SYNC_MAX_OP_PER_SYNC_DEFAULT_VALUE

        public static final int PERIODIC_SYNC_MAX_OP_PER_SYNC_DEFAULT_VALUE
        Default value used for the maximum number of operations to process per periodical sync.
        Since:
        10.0.8 / JCMS-10654
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        public static final LdapManager getInstance()
      • initLDAP

        public void initLDAP()
        Initialize or Reinitialize LDAP configuration.
      • getLDAPConfiguration

        public LDAPConfiguration getLDAPConfiguration()
        Returns the default LDAPConfiguration used by JCMS which you can give to LDAPMapper(LDAPConfiguration) to connect to your LDAP server.
        Returns:
        the current LDAPConfiguration used by JCMS
        Since:
        jcms-5.5.0
      • getLDAPConfigurationFromLogin

        public LDAPConfiguration getLDAPConfigurationFromLogin​(java.lang.String login)
        Retrieve the LDAPConfiguration to use based on the specified login.

        If the specified login is a mail, a Windows UPN (User Principal Name) format, or a down-level windows logon format (DOMAIN\sAMAccountName), the domain part is extracted and the LDAP configuration will be read from properties ldap.server.{DOMAIN}.* (if available) instead of the default ldap.server.* properties.
        Configuration alias can also be defined with property ldap.conf-aliases.{domain}: confname allowing several domain to match on LDAP configuration.

        Parameters:
        login - the login used to determine which configuration to use
        Returns:
        a LDAPConfiguration, never return null (default to getLDAPConfiguration().
      • getLDAPConfigurationFromDomain

        public LDAPConfiguration getLDAPConfigurationFromDomain​(java.lang.String domain)
        Retrieve the LDAPConfiguration for the specific domain.
        Parameters:
        domain - an optional configuration name or alias, as declared in ldap configuration properties ldap.server.{domain}.* or through LDAP configuration alias declared in property ldap.conf-aliases.{domain}: confname
        Returns:
        an instance of LDAPConfiguration, never return null (default to getLDAPConfiguration())
      • getLDAPConfigurations

        public java.util.List<LDAPConfiguration> getLDAPConfigurations()
        Returns all LDAPConfiguration configured in JCMS.
        Returns:
        a List of all LDAPConfigurations configured in JCMS, never return null
        Since:
        jcms-9.0.1
      • importAll

        public void importAll()
        Import all LDAP users (and their groups) in JCMS, updating existing data if any.

        For each LDAP configuration declared, this method retrieves all users in the LDAP matching the current filters and then trigger the synchronisation operation impletemented in the LdapAuthenticationHandler :
        create or update operation of corresponding Member and Group(s).

        All existing LDAP Member not found during the LDAP search are also processed to disable them as needed.

      • isImportAllInProgress

        public boolean isImportAllInProgress()
        Checks if an import all operation is in progress.
        Returns:
        true if importAll() is currently working, false otherwise
      • isLdapEnabled

        public boolean isLdapEnabled()
        Checks if LDAP is enabled.
        Returns:
        true if LDAP is enabled, false otherwise
      • getGroupFromDN

        public Group getGroupFromDN​(java.lang.String dn)
        Returns a LDAP group from its distinguish name.
        Parameters:
        dn - the dn of the group
        Returns:
        the group or null if not found
      • createDBMember

        public boolean createDBMember()
        Check type of Member to create during LDAP synchronization.
        Returns:
        false to create JStore Member, true to create DBMember
        Since:
        jcms-10.0.1 / JCMS-6340
      • getNewLdapContextMap

        public java.util.Map<java.lang.String,​java.lang.Object> getNewLdapContextMap()
        Retrieve a new context map indicating operation is being processed for LDAP.

        Implementation detail : the returned map will contain key {link DataController#CTXT_SYNC_LDAP} with value Boolean.TRUE

        Returns:
        a new Map
        Since:
        10.0.8 / JCMS-10691