使用 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)
我在这里看到类似的问题,但我找不到好的解决方案。
我的问题:
我有一个应用程序需要从连接字符串中检索数据,检索到的信息取决于经过身份验证的 windows 用户。当我 运行 在开发环境中使用 IIS Express 时,我得到了我的登录用户。
但是,当我通过 IIS Local 托管它时,我得到了 ( IIS APPPOOL\ ) 作为用户。我需要它成为 windows 用户。
即使我登录了,当我在我的视图中检查时,应用程序仍然输出 APPPOOL
有人对此有好的解决方案吗?
我试过了:
@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>
听起来您的应用程序总是模仿应用程序池标识。
我可以通过
获得正确的 windows 身份
System.Web.HttpContext.Current.User.Identity.Name
HttpContext.Current.Request.LogonUserIdentity.Name
User.Identity.Name;
首先,请确保您的身份验证看起来像这样。请同时禁用 impersonate 和 anonymous。
<location path="mysite">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
其次,请保证您的 windows 身份验证不会使用应用程序池凭据执行
最后,您应该获得正确的凭据。
我在这里看到类似的问题,但我找不到好的解决方案。
我的问题: 我有一个应用程序需要从连接字符串中检索数据,检索到的信息取决于经过身份验证的 windows 用户。当我 运行 在开发环境中使用 IIS Express 时,我得到了我的登录用户。
但是,当我通过 IIS Local 托管它时,我得到了 ( IIS APPPOOL\ ) 作为用户。我需要它成为 windows 用户。
即使我登录了,当我在我的视图中检查时,应用程序仍然输出 APPPOOL
有人对此有好的解决方案吗?
我试过了:
@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>
听起来您的应用程序总是模仿应用程序池标识。
我可以通过
获得正确的 windows 身份System.Web.HttpContext.Current.User.Identity.Name
HttpContext.Current.Request.LogonUserIdentity.Name
User.Identity.Name;
首先,请确保您的身份验证看起来像这样。请同时禁用 impersonate 和 anonymous。
<location path="mysite">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
其次,请保证您的 windows 身份验证不会使用应用程序池凭据执行
最后,您应该获得正确的凭据。