DirContext ctx;
try {
ctx = new InitialLdapContext(env, null);
} catch (javax.naming.CommunicationException e) {
throw new CommunicationException(e);
} catch (javax.naming.AuthenticationException e) {
throw new AuthenticationException(e);
} catch (javax.naming.AuthenticationNotSupportedException e) {
throw new AuthenticationNotSupportedException(e);
} catch (NamingException e) {
// Assume some kind of communication problem.
throw new CommunicationException(e);
}
return new JNDIDirContextAdaptor(ctx);
}