LDAP Active Directory查找来自两个OU的所有用户

我想查找所有包含在两个OU中的用户,但不是其他用户。 基本上,这是在https://ldapwiki.com/wiki/ExtensibleMatch#section-ExtensibleMatch-SearchWithinTwoContainers ,但在一个Active Directory中相同的问题。 那里的页面显示“Microsoft Active Directory不支持此function,只支持:Microsoft Active Directory可扩展匹配规则”。

我想从OUpipe理和人员中find所有用户,如下所示:

dc=com dc=willeke ou=Administration cn=OneInetOrgPerson .... ou=People cn=TwoInetOrgPerson .... ou=butler cn=moreInetOrgPerson .... ou=Groups cn=ThreeInetOrgPerson .... ou=IDM cn=FourInetOrgPerson .... ou=Sales cn=FiveInetOrgPerson .... 

我不明白如何使用Active Directory创build相同的function。 这是甚至可以与AD?

是的,你可以用PowerShell来做到这一点。

 Import-Module Active Directory $OUs = 'OU=Administration,DC=willeke,DC=com','OU=People 2,DC=willeke,DC=com' $OUs | ForEach { Get-ADUser -Filter * -SearchBase $_ } 

https://social.technet.microsoft.com/Forums/office/en-US/8354b35a-e4f8-428b-918f-a10ab3efa5d0/getaduser-effective-multiou-search?forum=winserverpowershell

https://www.experts-exchange.com/questions/28788079/Get-Users-from-multiple-OUs-with-Poweshell.html

正如user5870571指出的那样,您可以执行两个单独的查询并合并结果。

或者,您可以将search范围更改为更高级别的容器,并在客户端过滤结果。

 Get-ADUser -Filter * -SearchBase 'DC=willeke,DC=com' | Where-Object { $_.distinguishedName -like '*,OU=Administration,DC=willeke,DC=com' -or $_.distinguishedName -like '*,OU=People,DC=willeke,DC=com' }