我从Active Directory中提取用户列表,但我想跳过特定的组织单位,名称为" ServiceAccounts"。我的理解是,以下行不能解决我的问题,因为通配符不适用于DN:
search.Filter = "(&(objectCategory=person)(objectClass=user)(!(distinguishedName=*ServiceAccounts*))(mail=*))";
此OU包含大约150多个服务帐户的列表,在生成员工列表时我不需要这些帐户。我唯一的问题,如何不从特定的OU获取记录?
谢谢,非常感谢!
答案 0 :(得分:0)
在LDAP中,通常不允许在DN值范围内进行子字符串搜索。
Microsoft Active Directory专门the wildcard character cannot be used with Distinguished Name attributes (attributes of data type DN), such as the distinguishedName, memberOf, directReports, and managedBy attributes.
并且仅作为Microsoft Active Directory的supports specific Extensible Match规则,我认为这是不可能的。
此外,默认情况下," ou"未在用户条目上填充值,或者您可以使用:
(!(ou=ServiceAccounts))
在过滤器内。
某些编程环境似乎support a non-standard语法:
(&(objectClass=user)(!(distinguishedName:=%ServiceAccounts%)))
也许提供有关您的树结构的更多信息,有人可以提供解决方案。