[英]ASP.NET windows authentication with impersonation
I want to enable windows authentication for my ASP.NET intranet application. 我想为我的ASP.NET Intranet应用程序启用Windows身份验证。 For that, I did the below in my
web.config
file. 为此,我在
web.config
文件中执行了以下操作。
<system.web>
<authentication mode="Windows" >
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<identity impersonate="true" userName="domain\myusername" password="mypwd" />
</system.web>
And I am trying to access the authenticated user name in my web page as 我正在尝试以以下方式访问我的网页中经过身份验证的用户名:
HttpContext.Current.User.Identity.Name
It throws an "access denied" error message. 它将引发“访问被拒绝”错误消息。
Try using WindowsIdentity.Name
or WindowsIdentity.GetCurrent().Name
instead of HttpContext.Current.User.Identity.Name
. 尝试使用
WindowsIdentity.Name
或WindowsIdentity.GetCurrent().Name
而不是HttpContext.Current.User.Identity.Name
。
As far as adding roles to Claim
is concerned, you can add it with the help of some code. 就向
Claim
添加角色而言,您可以借助一些代码来添加它。 These links might help you : 这些链接可以帮助您:
Creating ClaimIdentity Object 创建ClaimIdentity对象
Claim Based Security in C# C#中基于声明的安全性
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.