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 应用程序池
基础教程推荐
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
