私はmain.com
、sub.main.com
、となどSystem.DirectoryServices.AccountManagementを使用して複数のドメインを検索するにはどうすればよいですか?
などの3つの以上のドメインを持っている私は、コードがあります。
using (PrincipalContext ctx =
new PrincipalContext(ContextType.Domain, "ADServer",
"dc=main,dc=com", ContextOptions.Negotiate))
{
UserPrincipal u = new UserPrincipal(ctx);
u.UserPrincipalName = "*" + mask + "*";
using (PrincipalSearcher ps = new PrincipalSearcher(u))
{
PrincipalSearchResult<Principal> results = ps.FindAll();
List<ADUser> lst = new List<ADUser>();
foreach (var item in results.Cast<UserPrincipal>().Take(15))
{
byte[] sid = new byte[item.Sid.BinaryLength];
item.Sid.GetBinaryForm(sid, 0);
ADUser us = new ADUser()
{
Sid = sid,
Account = item.SamAccountName,
FullName = item.DisplayName
};
lst.Add(us);
}
}
return lst;
}
をしかし、それは唯一のドメイン内を検索:main.com
。
一度にすべてのドメインのレコードを検索するにはどうすればよいですか?ここで
から私は考えていません一度に複数のドメインを検索することができます。検索を「シリアライズ」する必要があります。 –
あなたはドメインを知り、サイクルで検索しなければならないのですか? –