我想为我的ASP.NET Intranet应用程序启用Windows身份验证。
为此,我在web.config
文件中执行了以下操作。
<system.web>
<authentication mode="Windows" >
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<identity impersonate="true" userName="domain\myusername" password="mypwd" />
</system.web>
我正在尝试在我的网页中访问经过身份验证的用户名
HttpContext.Current.User.Identity.Name
它会拒绝接入&#34;错误信息。
答案 0 :(得分:3)
尝试使用WindowsIdentity.Name
或WindowsIdentity.GetCurrent().Name
代替HttpContext.Current.User.Identity.Name
。
就向Claim
添加角色而言,您可以在某些代码的帮助下添加角色。这些链接可能对您有所帮助:
希望这有帮助。