繁体   English   中英

具有模拟功能的ASP.NET Windows身份验证

[英]ASP.NET windows authentication with impersonation

我想为我的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

它将引发“访问被拒绝”错误消息。

尝试使用WindowsIdentity.NameWindowsIdentity.GetCurrent().Name而不是HttpContext.Current.User.Identity.Name

就向Claim添加角色而言,您可以借助一些代码来添加它。 这些链接可以帮助您:

创建ClaimIdentity对象

C#中基于声明的安全性

希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM