* contexts, in order to support the different paging implementations they provide.
* @return the initial LDAP Context
*/
private InitialLdapContext initializeLDAPContext() throws ResourceException {
// Create the root context.
InitialLdapContext initContext;
Hashtable connenv = new Hashtable();
connenv.put(Context.INITIAL_CONTEXT_FACTORY, this.config.getLdapContextFactory());
connenv.put(Context.PROVIDER_URL, this.config.getLdapUrl());
connenv.put(Context.REFERRAL, LDAP_REFERRAL_MODE);
// If username is blank, we will perform an anonymous bind.
// Note: This is not supported when using Sun's VLVs, so remove this if VLVs are used.
if(!this.config.getLdapAdminUserDN().equals("")) { //$NON-NLS-1$
connenv.put(Context.SECURITY_AUTHENTICATION, LDAP_AUTH_TYPE);
connenv.put(Context.SECURITY_PRINCIPAL, this.config.getLdapAdminUserDN());
connenv.put(Context.SECURITY_CREDENTIALS, this.config.getLdapAdminUserPassword());
} else {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "LDAP Username DN was blank; performing anonymous bind."); //$NON-NLS-1$
connenv.put(Context.SECURITY_AUTHENTICATION, "none"); //$NON-NLS-1$
}
if(this.config.getLdapTxnTimeoutInMillis() != -1) {
connenv.put("com.sun.jndi.ldap.connect.timeout", this.config.getLdapTxnTimeoutInMillis()); //$NON-NLS-1$
}
// Enable connection pooling for the Initial context.
connenv.put("com.sun.jndi.ldap.connect.pool", "true"); //$NON-NLS-1$ //$NON-NLS-2$
connenv.put("com.sun.jndi.ldap.connect.pool.debug", "fine"); //$NON-NLS-1$ //$NON-NLS-2$
try {
initContext = new InitialLdapContext(connenv, null);
} catch(NamingException ne){
final String msg = LDAPPlugin.Util.getString("LDAPConnection.directoryNamingError",ne.getExplanation()); //$NON-NLS-1$
throw new ResourceException(msg);
}
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Successfully obtained initial LDAP context."); //$NON-NLS-1$