WindowsIdentity 和经典 .Net 应用程序池 [英] WindowsIdentity and Classic .Net App Pool

查看:21
本文介绍了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 应用程序池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆