[英]Hosting a mvc app via IIS with windows authentication, but I get IIS APPPOOL\ APP I need the windows user that connects (works with IIS express)
I saw similar questions like this on here but I simply can't find a good solution.我在这里看到了类似的问题,但我根本找不到一个好的解决方案。
My problem: I have an app that need to retrieve data from a connection string, and information that is retrieved depends on the authenticated windows user.我的问题:我有一个应用程序需要从连接字符串中检索数据,而检索到的信息取决于经过身份验证的 Windows 用户。 When I run this in dev environment with IIS Express I get my logged in user.
当我使用 IIS Express 在开发环境中运行它时,我得到了我的登录用户。
However when I host it via IIS Local i get ( IIS APPPOOL\\ ) as the user.但是,当我通过 IIS Local 托管它时,我以用户身份获得( IIS APPPOOL\\ )。 I need this to be the windows user.
我需要这是 Windows 用户。
Even tho I get the login the application still outputs APPPOOL when I check this in my views即使我获得了登录信息,当我在视图中查看此应用程序时,它仍会输出 APPPOOL
Anyone with a good solution to this?有没有人对此有好的解决方案?
I tried:我试过:
@System.Web.HttpContext.Current.User.Identity.Name
@System.Security.Principal.WindowsIdentity.GetCurrent().Name
@HttpContext.Current.Request.LogonUserIdentity.Name
<system.web>
<authentication mode="Windows" />
<authorization>
<allow users="*" />
<deny users="?" />
</authorization>
<identity impersonate="true" />
<trace enabled="true" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
It sounds like your application are always imepersonate as application pool identity.听起来您的应用程序总是模仿应用程序池身份。
I can get the correct windows identity via我可以通过以下方式获得正确的 Windows 身份
System.Web.HttpContext.Current.User.Identity.Name
HttpContext.Current.Request.LogonUserIdentity.Name
User.Identity.Name;
First of all, please ensure your authentication looks like this.首先,请确保您的身份验证如下所示。 Please disable impersonate and anonymous at the same time.
请同时禁用模拟和匿名。
<location path="mysite">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
Secondly,please promise your windows authentication are not executed with app pool credential其次,请保证您的 Windows 身份验证不使用应用程序池凭据执行
Finally, you should get the correct credential.最后,您应该获得正确的凭证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.