简体   繁体   English

通过带有 Windows 身份验证的 IIS 托管 mvc 应用程序,但我得到 IIS APPPOOL\\ APP 我需要连接的 Windows 用户(与 IIS express 一起使用)

[英]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.

相关问题 MVC 身份验证在 IIS 中不起作用(在 IIS Express 中起作用) - MVC Authentication not working in IIS (works in IIS Express) 集成Windows身份验证不适用于IIS上的MVC .NET Web应用 - Integrated Windows Authentication not working for MVC .NET web app on IIS 在IIS Web应用程序中,如何获取Windows用户名? -不是进程用户名 - in an IIS web app, how do I get the windows user name? - not the process username IIS Windows身份验证IIS APPOOL - IIS Windows Authentication IIS APPOOL 我无法在IIS网站上使用Windows身份验证 - I can't get windows authentication to work on IIS website 使用在域上具有Windows身份验证的IIS,我可以以发起对IIS的请求的域用户身份启动进程吗? - With IIS with Windows authentication on domain, can I start a process as the domain user who initiated request to IIS? Windows 授权适用于 IIS Express 上的调试,但不适用于 IIS 服务器 - Windows Authorization works in debug on IIS Express but not in IIS server MVC 5 身份验证在 IIS Express 中工作但不在 IIS 中 - MVC 5 Authentication working in IIS Express but not in IIS Windows IIS 中的身份验证问题 - Windows Authentication problems in IIS IIS要求Windows身份验证 - IIS asking for windows authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM