myUserList AppUsers = new myUserList();
using (PrincipalContext pcxt = new PrincipalContext(ContextType.Domain, domainName))
{
UserPrincipal User = new UserPrincipal(pcxt);
User.EmailAddress = emailString;
PrincipalSearcher srch = new PrincipalSearcher(User);
foreach (var principal in srch.FindAll())
{
var p = (UserPrincipal)principal;
myUserRow User = AppUsers.NewUsersRow();
User.FirstName = p.GivenName;
User.LastName = p.Surname;
User.Email = p.EmailAddress;
AppUsers.AddUsersRow(User);
}
}
私はActive DirectoryでPrincipalContextクラスを使用してユーザー情報を検索するようなコードを用意しています。検索方法PrincipalContextを使用してグローバルカタログ(フォレスト全体)
ご覧のとおり、私は検索中にdomainNameを渡します。 このコードを変更して、フォレスト全体(グローバルカタログなど)を検索する代わりに、PrincipalContextクラスを使用するにはどうすればよいですか?
私は、PrincipalContextクラスを使用してグローバルカタログ検索を行う実際の例を見つけることができません。
この投稿はHow to search for users in Global Catalog within AD forest with multiple treesですが、ポスターはPrincipalContextクラスを使用するソリューションを見つけられなかったことを示唆しているようで、DirectorySearcherに戻る必要がありました。
フォレスト全体(グローバルカタログ)での検索を示すPrincipalContextクラスコードサンプルはありますか?