我想使用 Id 从 LDAP Active Directory 中获取一些用户信息。这是我试图连接并获取它的代码。
SearchControls ctls = new SearchControls();
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration results = ctx.search("DC=erieinsurance,DC=com", "(&(objectCategory=user)(name{0}))",
new Object[]{Id}, // filter arguments
ctls); // search controls
}
if (results.hasMoreElements()) {
}
它没有返回给定名称和 sn 的对应值。
上面的过滤器有什么问题吗?任何建议将不胜感激。