C# で Active Directory にクエリを実行すると、奇妙な問題が発生します。
var ctx = new PrincipalContext(ContextType.Domain, "adr", "usr", "pwd");
var entry = new DirectoryEntry("LDAP://" + adr, usr, pwd);
var searcher = new DirectorySearcher(entry) { Filter = "(&(sAMAccountName=user_to_search))", PageSize = 2000 };
foreach (SearchResult searchUser in searcher.FindAll())
{
// groups
var groups = searchUser.GetPropertyValues("memberof");
}
var groups = UserPrincipal.FindByIdentity(ctx, "usr_to_search").GetGroups(ctx).ToList();
しかし、結果は同じではありません:
- リターンズ
PrincipalSearcher
14 グループ - リターンズ
DirectorySearcher
12 グループ
さて、これはバグですか、それとも何か見逃したのでしょうか?
ありがとう