[英]Adding ASP.NET impersonation users of specific domain to windows authentication
我在公司(IIS 7.5)的Windows Server 2008中安装了MVC4应用程序。 要远程访问Windows服务器,我们使用(xxxxDMZ \\ username,password),这与访问网站的特定页面所需的Windows身份验证相同。 我的问题是不是每个人都拥有此“ xxxxDMZ”帐户,所以他们无法访问该页面,我要做的是添加其Windows登录凭据以访问该页面(仅添加用户名),该用户名将为“ xxxx \\用户名'。
我读过这篇文章,为了做到这一点,我必须使用模拟,但是我找不到实现它的明确方法。
非常感谢任何帮助。
提前非常感谢您!
这是您可以使用的功能。 但是需要从DMZ访问域...这意味着在DMZ和域控制器之间打开端口。
public bool ValidateUser(string userName, string password)
{
bool validation;
try
{
LdapConnection ldc = new LdapConnection(new LdapDirectoryIdentifier((string)null, false, false));
NetworkCredential nc = new NetworkCredential(userName, password, "DOMAIN NAME HERE");
ldc.Credential = nc;
ldc.AuthType = AuthType.Negotiate;
ldc.Bind(nc); // user has authenticated at this point, as the credentials were used to login to the dc.
validation = true;
}
catch (LdapException)
{
validation = false;
}
return validation;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.