1
私はUserPrincipalを返しますが、loginnameにdomainnameを含めないでください。プロパティ "Domainname"などはありません。UserPrincipalまたはPrincipalSearcherからドメイン名を取得する方法
UserPrincipalまたはPrincipalSearcherからドメインをユーザー/返されたユーザーに取得するにはどうすればよいですか?
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
UserPrincipal user = new UserPrincipal(ctx);
user.SamAccountName = txtSearch.Text;
PrincipalSearcher searcher = new PrincipalSearcher(user);
PrincipalSearchResult<Principal> results = searcher.FindAll();
foreach (UserPrincipal u in results)
{
Response.Write(u.Name + "<br />");
}
この質問は次のとおりです。http://stackoverflow.com/questions/10702188/where-is-the-domain-name-in-a-userprincipal-objectは似ていますが、受け入れられない回答があります。http:// stackoverflow.com/questions/4284641/get-netbiosname-from-a-userprincipal-object –