use of com.zimbra.cs.ldap.unboundid.InMemoryLdapServer 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;
}
Aggregations