我正在尝试验证用户是否在“ TestGroup”组中。该用户是“ TestGroup”组的一部分,即使我正在获取retval = false @line(retVal = user.IsMemberOf(groupPrincipal);),并且在事件查看器中,它也将msg显示为“用户名或密码不正确” ”。
你能帮我吗
string userName = this.Request.ServerVariables["AUTH_USER"];
if (ValidateUser(userName) == false)
Response.Redirect("Error.aspx?errormsg=" + userName + " does not have permission to view this page");
public static bool ValidateUser(String userName)
{
bool useGroupAuthorization = true;
if (useGroupAuthorization)
return GroupLookup(userName, "TestGroup");
}
private static bool GroupLookup(string userName, string groupName)
{
System.Diagnostics.EventLog appLog = new System.Diagnostics.EventLog();
appLog.Source = "Test App";
bool retVal = false;
PrincipalContext pc = null;
UserPrincipal user = null;
GroupPrincipal groupPrincipal = null; …Run Code Online (Sandbox Code Playgroud)