我现在知道我选中的那个一级.我想通过查询获得下面所有的子级节点. 主要的是下面的子级节点的类型不一样.全部都要获取.SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration en = ctx.search("", "(cn=YZQZF)", constraints);我的查询条件是这样, 但是只有查出一条数据来.而且是当前对象.
LDAPSpringAD查询
在你使用subtree范围的基础上,试试加一个filter,把objectClass设置成top,还有,你第一个参数应该需要指定一下,那表示一个节点的名称:
NamingEnumeration en = ctx.search(new LdapName("cn=YZQZF"), "&(cn=YZQZF)(objectClass=top)", constraints);大概是这么写,我这没环境,你试试。
NamingEnumeration en = ctx.search(new LdapName("cn=YZQZF"), "(objectClass=top)", constraints);
这是我的Ldap树形结构:
所以必须要把ROOT节点带上.而且必需从左到右写.从小范围到大范围.