How to get error messages from DirContext?

时间:2019-04-08 13:09:15

标签: java ldap

Im using DirContext for connection to LDAP server. How to get information about errors of this context? Server is not avaliable, password not correct or user is blocked and etc

Hashtable<String, String> envoironment = new Hashtable<>();
        envoironment.put(Context.INITIAL_CONTEXT_FACTORY, 
"com.sun.jndi.ldap.LdapCtxFactory");
        // envoironment.put(Context.PROVIDER_URL, "******");
        envoironment.put(Context.PROVIDER_URL, "******");
        envoironment.put(Context.SECURITY_AUTHENTICATION, 
"simple");
        envoironment.put(Context.SECURITY_PRINCIPAL, username 
+ "@somdomain.com");
        envoironment.put(Context.SECURITY_CREDENTIALS, 
password);

DirContext context = new InitialDirContext(envoironment);

0 个答案:

没有答案