WindowsIdentity and Classic .Net App Pool(WindowsIdentity 和经典 .Net 应用程序池)
问题描述
我有一个 ASP.NET 网站,要求我的应用程序池是经典 .Net 应用程序池.该站点在 IIS 7 上的 .NET 3.5 上运行.当我尝试获取登录用户的 Active Directory 用户名时:
I have a ASP.NET website that requires my App Pool be the Classic .Net App Pool. The site is running on .NET 3.5 on IIS 7. When I try to get the Active Directory User name of the logged in user:
System.Security.Principal.WindowsIdentity.GetCurrent().Name
我得到以下信息:
IIS APPPOOL\Classic .NET AppPool
但是,当我将应用程序池设置为 .net 4.0 时,它会返回登录的用户名(这是我想要的).我错过了一个设置吗?
However when I set the app pool to .net 4.0 it returns the logged in username (which is what I want). Am I missing a setting?
推荐答案
首先把这行放在web.config配置部分:
First of all put this lines inside web.config configuration section:
<authentication mode="Windows"/>
<authorization>
<deny users="?"/>
</authorization>
<identity impersonate="true"/>
第二次去 IIS 管理器打开你的 Web 应用属性并检查以下身份验证设置:
Second go to IIS manager open your web app properties and check following settings for Authentication:
匿名身份验证 = 已禁用,ASP.NET Impersonation = 已启用(这不是必需的),Windows 身份验证 = 已启用
Anonymous Authentication = Disabled, ASP.NET Impersonation = Enabled (this is not realy required), Windows Authentication = Enabled
此设置将为您提供 Active Directory 用户并模拟它.
This settings will give you Active Directory User and also impersonate it.
这篇关于WindowsIdentity 和经典 .Net 应用程序池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:WindowsIdentity 和经典 .Net 应用程序池


- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01