最近ExtendedUserPrincipal
、サンプルhereのようなカスタム クラスを実装しています。UserPrincipal.Current
私にとって唯一の問題は、既存のユーザー プリンシパルを拡張バージョンにマップするために、基本クラスの既存のインスタンス (例: ) に基づいて新しいインスタンスを構築することです。
今のところ、ドメイン コンテキストの明示的な作成を使用しています。
var ctx = new PrincipalContext(ContextType.Domain, "domain.name");
return ExtendedUserPrincipal.FindByIdentity(ctx,
IdentityType.Sid, user.Sid.ToString());
ドメインコンテキストを明示的に指定せずに構築するためにやりたいこと、例えば
return Extended.UserPrincipal.FindByIdentity(SomeHelper.GetDomainContext(user),
user.Sid, user.Sid.ToString());
これは可能ですか、または設計上禁止されていますか (おそらくセキュリティ上の懸念)?user.Context
ここでは役に立ちません。