【发布时间】:2014-11-17 05:41:21
【问题描述】:
Hashtable env = new Hashtable(11);create environment
env.put(上下文.INITIAL_CONTEXT_FACTORY,
“com.sun.jndi.ldap.LdapCtxFactory”);
env.put(Context.PROVIDER_URL, "ldap://localhost:10389/ou=system");url Declaration
env.put(Context.SECURITY_CREDENTIALS, "秘密");
env.put(Context.SECURITY_AUTHENTICATION, "简单");
env.put(Context.SECURITY_PRINCIPAL, "ou=121,ousystem");For this is Domain
env.put(Context.SECURITY_CREDENTIALS, "secret");set new credential
// 搜索和检索 DN。
DirContext ctx = null;
NamingEnumeration results = null;
try {
ctx = new InitialDirContext(env);`cant create obj here`
SearchControls controls = new SearchControls();
// Authenticate
ldap = new InitialLdapContext(env, null);
} catch (AuthenticationException ae) {
ae.printStackTrace();
} catch (NamingException e) {
e.printStackTrace();
}
错误:javax.naming.NameNotFoundException:when creating obj for context
【问题讨论】:
标签: java security authentication ldap credentials