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 应用程序池
基础教程推荐
- WPF 模态进度窗口 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
