2
对不起,我在JNDI noob,我尝试连接到我的LDAPS与JNDI简单的身份验证,但我不知道我怎么可以在连接后获取数据所以我的代码是:我如何从JNDI获取数据ldap
public static void main(String[] args) {
// Set up environment for creating initial context
Hashtable<String, String> env = new Hashtable<String, String>(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldaps://myadress:636");
// Authenticate as S. User and password "mysecret"
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "my BASE DN");
env.put(Context.SECURITY_CREDENTIALS, "mypass");
try {
// Create initial context
DirContext ctx = new InitialDirContext(env);
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
e.printStackTrace();
}
}
后
DirContext ctx = new InitialDirContext(env);`
我希望得到我的树和一些数据,但如何..例如我的树是:
-ou=people,dc=info,dc=uni,dc=com
---ou=students
-----uid=5tey37
我怎么能获取uid的数据?
对不起,我是个菜鸟,和对不起我的英语
伟大的!非常感谢! – FelasDroid
@FelasDroid不客气 – PopoFibo