ユーザーが特定のADグループのメンバーであるかどうかを判断するコードを強化しようとしています。これは基本的に、グループのメンバーが外国のセキュリティプリンシパルとして保存されているために別の(信頼できる)ドメインからのものである場合を除いて機能します。
テストするグループとチェックするアカウントの両方に有効なDirectoryEntryオブジェクトがある場合、アカウントがそのグループに含まれていることを確認できるDirectorySearcherFilter文字列が必要です。外国のセキュリティプリンシパルです。
(問題を示すVB.NETコードサンプル)
Dim ContainerGroup as DirectoryEntry = ... Code to get Group
Dim UserToCheckFor as DirectoryEntry = ... Code to get User
DSearcher = New DirectorySearcher(ContainerGroup, "(WHATCANIPUTINHERE)", New String() {"member;Range=0-5000"}, SearchScope.Base)
DSearcher.AttributeScopeQuery = "member"
'If an object is found, the account was in the group
Return (DSearcher.FindOne() IsNot Nothing)