System.DirectoryServices.DirectorySearcher ReferralChasing 和 PageSize 在一起
System.DirectoryServices.DirectorySearcher ReferralChasing and PageSize together
我想知道为什么 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 中。
我在 MSDN 论坛上交叉发布了这个并得到了答案。引用他们的答案:
According to documentation for ReferralChasing, “All” includes
“Subordinate”, and “the ADSI LDAP provider always turns off this flag
for paged searches” for some reasons
[https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices.referralchasingoption?view=netframework-4.7.1].
我想知道为什么 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 中。
我在 MSDN 论坛上交叉发布了这个并得到了答案。引用他们的答案:
According to documentation for ReferralChasing, “All” includes “Subordinate”, and “the ADSI LDAP provider always turns off this flag for paged searches” for some reasons [https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices.referralchasingoption?view=netframework-4.7.1].