0
VB.netアプリケーション内でユーザーIDのドロップダウンリストを作成するコードがあります。一部のユーザー名は返されません。私は1000を超えていますので、1000の限界にはならないと思われます。検索フィルターに(sAMAccountName = Kry *)を追加すると、表示されていないユーザー(kryで始まる名前)が返されます。これに関する助けがあれば大いに感謝します。ありがとう!Active Directory検索ですべてのユーザーが返されない
Private Sub PopSecurityUser()
cboUser.Items.Clear()
Dim SearchRoot As DirectoryEntry = ActiveDirectory.Forest.GetCurrentForest.RootDomain.GetDirectoryEntry '< More portable. Discover domain root DirectoryEntry rather than hard coding a Global Catalog.
Dim AdObj As System.DirectoryServices.SearchResult
Dim Searcher As New DirectorySearcher(SearchRoot)
With Searcher
.PropertiesToLoad.Add("sAMAccountName")
.SearchScope = SearchScope.Subtree
.Filter = "(&(!objectClass=contact)(objectCategory=person)(objectClass=user))" '< Exclude contacts because they don't have a sAMAccountName property.
.ReferralChasing = ReferralChasingOption.All '< Causes lookups to follow LDAP referrals if the object doesn't exist on the queried domain controller.
End With
For Each AdObj In Searcher.FindAll
If Not IsNumeric(AdObj.Properties("sAMAccountName")(0).ToString.Substring(0, 1)) Then
cboUser.Items.Add(AdObj.Properties("sAMAccountName")(0))
End If
Next
cboUser.Sorted = True
End Sub
私はそれが1000の制限だとは思わないので、私は1232人のユーザーを得ていました。私は無効なアカウントを除外するために(userAccountControl = 512)を追加してしまいました。そして今、私は失われたユーザーを含め約800行を返します。 – gcresse
ああ、申し訳ありませんが、何とか「1000以上返された」声明を見過ごしたに違いありません。それにもかかわらず、私はあなたが解決策を見つけることができてうれしいです。 – David