Search in sources :

Example 1 with UBIDLdapClient

use of com.zimbra.cs.ldap.unboundid.UBIDLdapClient in project zm-mailbox by Zimbra.

the class LdapClient method getInstanceIfLDAPavailable.

static synchronized LdapClient getInstanceIfLDAPavailable() throws LdapException {
    if (ldapClient == null) {
        if (InMemoryLdapServer.isOn()) {
            try {
                InMemoryLdapServer.start(InMemoryLdapServer.ZIMBRA_LDAP_SERVER, new InMemoryLdapServer.ServerConfig(Lists.newArrayList(LdapConstants.ATTR_dc + "=" + InMemoryLdapServer.UNITTEST_BASE_DOMAIN_SEGMENT)));
            } catch (Exception e) {
                ZimbraLog.system.error("could not start InMemoryLdapServer", e);
            }
        }
        String className = LC.zimbra_class_ldap_client.value();
        if (className != null && !className.equals("")) {
            try {
                ldapClient = (LdapClient) Class.forName(className).newInstance();
            } catch (Exception e) {
                ZimbraLog.system.error("could not instantiate LDAP client '" + className + "'; defaulting to JNDI LDAP SDK", e);
            }
        }
        if (ldapClient == null) {
            ldapClient = new UBIDLdapClient();
        }
        ldapClient.init(ALWAYS_USE_MASTER);
    }
    return ldapClient;
}
Also used : InMemoryLdapServer(com.zimbra.cs.ldap.unboundid.InMemoryLdapServer) UBIDLdapClient(com.zimbra.cs.ldap.unboundid.UBIDLdapClient) ServiceException(com.zimbra.common.service.ServiceException)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)1 InMemoryLdapServer (com.zimbra.cs.ldap.unboundid.InMemoryLdapServer)1 UBIDLdapClient (com.zimbra.cs.ldap.unboundid.UBIDLdapClient)1