我已阅读此帖子,但无法使其正常运行。
LDAP Query to list all users of a certain group
我尝试了什么:
using (DirectoryEntry oDirEnTry = new DirectoryEntry(ldapConnectPath, UserDN, LdapConfig.LdapPassword, AuthenticationTypes.ServerBind))
using (DirectorySearcher oLdapSearch = new DirectorySearcher(oDirEnTry))
oLdapSearch.Filter = "(&(objectCategory=user)(memberOf=cn= " + roleName + ",ou=Groups,dc=company,dc=com))";
SearchResultCollection oSearchCollection = oLdapSearch.FindAll();
但是oSearchCollection没有回复我。为什么?我确信我的roleName下有用户。
仅供参考,我设法反向...下面的查询成功地将所有标记给特定用户的角色归还给我:
oLdapSearch.Filter = "(uniqueMember=uid=" + userId + ",ou=People,dc=company,dc=com)";