我有一个运行 ASP.NET MVC 的小型 Web 服务器。服务器与用户“abc”一起运行,但用户“abc”没有 ActiveDirectory 中的“更改”权限。
所以我必须通过 PrincipalContext 中的用户登录。
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, null, user, password))
{
GroupPrincipal theGroup = GroupPrincipal.FindByIdentity(context, groupId);
theGroup.Members.Add(context, IdentityType.SamAccountName, userId);
theGroup.Save();
}
该准则确实有效。但是我不喜欢将密码从 Methode 转移到 Methode... => 在 MVC 上我有一个 SSO,服务器知道我
System.Web.HttpContext.Current.User.Identity
可以使用此信息吗?
new PrincipalContext(ContextType.Domain, null, [System.Web.HttpContext.Current.User]) ???
或者我必须提供密码。以及如何最好地从视图传递到此方法。
谢谢