LDAP+;Java:我如何知道我的active directory';s的名字
我如何知道我的active directory的所有属性 我看到了“ou=People”这样的例子,但我不知道如何访问公司中特定的“People”名称。我不能访问LDAP(或者我不知道如何访问),所以我不知道应该放什么LDAP+;Java:我如何知道我的active directory';s的名字,java,eclipse,attributes,active-directory,Java,Eclipse,Attributes,Active Directory,我如何知道我的active directory的所有属性 我看到了“ou=People”这样的例子,但我不知道如何访问公司中特定的“People”名称。我不能访问LDAP(或者我不知道如何访问),所以我不知道应该放什么 DirContext ctx = null; Hashtable<String, Object> env = new Hashtable<String, Object>(); env.put(Conte
DirContext ctx = null;
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://"+serverAddress+":389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, DOMAIN+username);
env.put(Context.SECURITY_CREDENTIALS, password);
try {
ctx = new InitialDirContext(env);
Attributes matchAttrs = new BasicAttributes(true); // ignore attribute name case
matchAttrs.put(new BasicAttribute("mail", "XXXXXX@XXXX.com"));
Attributes attrs = ctx.getAttributes("");
// Search for objects that have those matching attributes
NamingEnumeration<SearchResult> answer = ctx.search("ou=Users", matchAttrs);
while (answer.hasMore()) {
SearchResult sr = (SearchResult)answer.next();
System.out.println(">>>" + sr.getName());
}
DirContext ctx=null;
Hashtable env=新的Hashtable();
put(Context.INITIAL\u Context\u工厂,“com.sun.jndi.ldap.LdapCtxFactory”);
env.put(Context.PROVIDER_URL,“ldap://”+serverAddress+“:389”);
环境put(Context.SECURITY_认证,“simple”);
环境放置(Context.SECURITY\u主体,域+用户名);
环境放置(Context.SECURITY\u凭证、密码);
试一试{
ctx=新的初始目录上下文(env);
Attributes matchAttrs=new BasicAttributes(true);//忽略属性名称大小写
matchAttrs.put(新的基本属性(“邮件”)XXXXXX@XXXX.com"));
Attributes attrs=ctx.getAttributes(“”);
//搜索具有这些匹配属性的对象
namingumerationanswer=ctx.search(“ou=Users”,matchAttrs);
while(answer.hasMore()){
SearchResult sr=(SearchResult)answer.next();
System.out.println(“>>>”+sr.getName());
}
我有一个错误:绑定到LDAP失败[LDAP:错误代码1-000020D6:SvcErr:DSID-03100754,问题5012(DIR\u错误),数据0剩余名称“ou=Users”
我如何知道公司在ou=..之后使用哪个名称
非常感谢!您可以使用ldap浏览器浏览ldap。(我通常使用softerra ldap管理员)
您需要连接的所有信息都在代码的第一行(地址、端口等)您可以使用ldap浏览器浏览ldap。(我通常使用softerra ldap administrator)
您需要连接的所有信息都在代码的第一行内(地址、端口等…)