1

最近我一直在实现ExtendedUserPrincipal类似于 sample 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在这里没有帮助。这是可能的还是设计禁止的(可能是安全问题)?

4

0 回答 0