throws LdapDAOException
{
DefaultLdapContextFactory defaultLdapContextFactory = new DefaultLdapContextFactory();
if (ldapServer == null) {
throw new LdapDAOException("Ldap connection is not configured.");
}
CConnectionInfo connInfo = ldapServer.getConnectionInfo();
String url;
try {
if (useBackupUrl) {
url = new LdapURL(connInfo.getBackupMirrorProtocol(), connInfo.getBackupMirrorHost(), connInfo
.getBackupMirrorPort(), connInfo.getSearchBase()).toString();
}
else {
url = new LdapURL(connInfo.getProtocol(), connInfo.getHost(), connInfo.getPort(), connInfo
.getSearchBase()).toString();
}
}
catch (MalformedURLException e) {
// log an error, because the user could still log in and fix the config.
logger.error("LDAP Configuration is Invalid.");
throw new LdapDAOException("Invalid LDAP URL: " + e.getMessage());
}
defaultLdapContextFactory.setUsePooling(true);
defaultLdapContextFactory.setUrl(url);
defaultLdapContextFactory.setSystemUsername(connInfo.getSystemUsername());