System.DirectoryServices.DirectorySearcher ReferralChasing和PageSize在一起

时间:2017-11-14 15:34:09

标签: powershell active-directory ldap directorysearcher

我想知道为什么ReferralChasingPageSize不能与System.DirectoryServices.DirectorySearcher一起使用?

此代码没有PageSize,会追踪推介并向我显示所有帐户:

[System.DirectoryServices.DirectoryEntry] $objRoot = New-Object [System.DirectoryServices.DirectoryEntry("GC://DC=comapny,DC=com")
[System.DirectoryServices.DirectorySearcher] $objSearcher = New-Object System.DirectoryServices.DirectorySearcher($objRoot)

$objSearcher.SearchScope = "Subtree"
$objSearcher.ReferralChasing = "All"
$objSearcher.PropertiesToLoad.AddRange("name,distinguishedName".split(","))

$objSearcher.Filter = "(&(objectCategory=person)(objectClass=user)(memberOf=CN=one,OU=two,OU=three,DC=dingo,DC=company,DC=com))"
$objSearcher.FindAll()

但是此代码PageSize不会向我显示所有帐户。

[System.DirectoryServices.DirectoryEntry] $objRoot = New-Object [System.DirectoryServices.DirectoryEntry("GC://DC=comapny,DC=com")
[System.DirectoryServices.DirectorySearcher] $objSearcher = New-Object System.DirectoryServices.DirectorySearcher($objRoot)

$objSearcher.SearchScope = "Subtree"
$objSearcher.ReferralChasing = "All"
$objSearcher.PageSize = 1000
$objSearcher.PropertiesToLoad.AddRange("name,distinguishedName".split(","))

$objSearcher.Filter = "(&(objectCategory=person)(objectClass=user)(memberOf=CN=one,OU=two,OU=three,DC=dingo,DC=company,DC=com))"
$objSearcher.FindAll()

为了这个问题,它不会告诉我的帐户是" CN=user,OU=some,OU=folder,DC=bingo,DC=company,DC=com"。请注意该帐户在不同的DC中的情况。

1 个答案:

答案 0 :(得分:0)

我已经在MSDN论坛上发布了这个并得到了答案。引用他们的答案:

  

根据ReferralChasing的文档,“All”包括   “Subordinate”和“ADSI LDAP提供程序始终关闭此标志   对于分页搜索“出于某些原因   [https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices.referralchasingoption?view=netframework-4.7.1]

https://social.msdn.microsoft.com/Forums/en-US/4f2e4f81-a581-4006-a85f-218cb55a7b8a/systemdirectoryservicesdirectorysearcher-referralchasing-and-pagesize-together?forum=netfxbcl