Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java LDAP未返回所有属性_Java_Active Directory_Ldap_Adam_Adlds - Fatal编程技术网

Java LDAP未返回所有属性

Java LDAP未返回所有属性,java,active-directory,ldap,adam,adlds,Java,Active Directory,Ldap,Adam,Adlds,我正在使用Ldap从AD LDS检索帐户: Hashtable props = new Hashtable(); props.put(Context.SECURITY_PRINCIPAL, "cn=adminuser,o=myorg,c=uk"); props.put(Context.SECURITY_CREDENTIALS, "password"); props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFac

我正在使用Ldap从AD LDS检索帐户:

Hashtable props = new Hashtable();
props.put(Context.SECURITY_PRINCIPAL, "cn=adminuser,o=myorg,c=uk");
props.put(Context.SECURITY_CREDENTIALS, "password");
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
props.put(Context.PROVIDER_URL, "ldaps://myldapserver:636");
InitialLdapContext context = new InitialLdapContext(props, null);

SearchControls controls = new SearchControls();
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
controls.setReturningAttributes(null);
    // according to javadoc, null means "return all attributes"

NamingEnumeration<SearchResult> results =
    context.search(userBase, "cn=SOMEUSER", controls);
然后它神奇地回来了

为什么??
SearchControl
javadoc是否撒谎

我如何告诉它我真的想要所有属性回来


解决方法是列出我想要返回的每个属性。但这很可怕,而且会使添加未来字段非常容易出错。

密码控制属性是操作属性,除非您特别要求,否则不会返回这些属性

我如何告诉它我真的真的想要所有的属性回来


指定
新字符串[]{“*”,“+”}
作为要返回的属性ID:
“*”
表示所有非操作属性,
“+”
表示所有操作属性。但这通常不是一个好主意。有许多与您无关的操作属性。只需询问您实际需要的内容。

您是否尝试过从代码中删除setRetuningAttributes(null)行。@Shriram这没有任何区别。这是默认值。即使使用*也不会返回该值。其他人都来了。如何同时使用*和该值?@Anand_5050这是因为你没有按照我的回答去做。这是正确的吗?应该是:“*”表示所有非操作属性,“+”表示所有操作属性
controls.setReturningAttributes(new String[] {
    "msDS-UserPasswordExpired", "cn", "mail"
});