我想知道为什么ReferralChasing
和PageSize
不能与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中的情况。
答案 0 :(得分:0)
我已经在MSDN论坛上发布了这个并得到了答案。引用他们的答案:
根据ReferralChasing的文档,“All”包括 “Subordinate”和“ADSI LDAP提供程序始终关闭此标志 对于分页搜索“出于某些原因 [https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices.referralchasingoption?view=netframework-4.7.1]