简体   繁体   English

ASP.Net Web窗体应用程序不通过Windows身份验证在服务器上进行身份验证 - 模拟失败

[英]ASP.Net Web Forms App does not authenticate on server with Windows Authentication - fails impersonate

I am running an ASP.NET (VB) 4.6.1 Web Forms application. 我正在运行ASP.NET(VB)4.6.1 Web窗体应用程序。 I am using Windows Authentication ( <authentication mode="Windows" /> ). 我正在使用Windows身份验证( <authentication mode="Windows" /> )。
The scenario is to allow any authenticated Windows user to the landing page. 该方案是允许任何经过身份验证的Windows用户访问登录页面。 Any user in the “Check Admins” active directory security group should get access to any of the pages in the Admin sub-folder. “检查管理员”活动目录安全组中的任何用户都应该可以访问管理员子文件夹中的任何页面。

The root web.config has: 根web.config有:

<authorization>
  <deny users="?" />
</authorization>

The Admin web.config has: Admin web.config具有:

  <authorization>
    <allow roles="domain\Check Admins" />        
    <deny users="*" />
  </authorization>

On the landing page, I enumerate through all the roles the user has with: 在目标网页上,我列举了用户拥有的所有角色:

test &= "<br/><h3>You have the following roles:</h3>"
For Each r In Roles.GetRolesForUser()
    test &= r & "<br/>"
Next

I've gone through several setting and web.config changes (most outlined below). 我已经完成了几个设置和web.config更改(大部分概述如下)。 I can get it to work as expected on my dev PC but cannot get it to work when deployed to the test server running Windows 2008 R2 and IIS 7.5. 我可以在我的开发PC上按预期工作但在部署到运行Windows 2008 R2和IIS 7.5的测试服务器时无法使其工作。 I can get the site to come up some times, but only if I go to http://localhost . 我可以让网站出现一段时间,但前提是我去了http:// localhost It doesn't come up when I use the fully qualified name: http:// test.mysite.net 当我使用完全限定名称时,它不会出现:http:// test.mysite.net

Here are the changes & settings I've tried: 以下是我尝试过的更改和设置:

When running without impersonation: 在没有假冒的情况下跑步时:

Dev Machine: 开发机器:

  • User.Identity.Name: domain\\me User.Identity.Name:domain \\ me
  • Principal.WindowsIdentity.GetCurrent.Name: domain\\me Principal.WindowsIdentity.GetCurrent.Name:domain \\ me
  • Landingpage: Runs 登陆:运行
  • Admin page: Runs 管理页面:运行
  • Enumerated roles: All for me except admin roles 枚举角色:除管理员角色外,对我来说都是

All works as expected. 一切都按预期工作。

When deployed to the server with IIS Settings 使用IIS设置部署到服务器时 在此输入图像描述

IIS 7.5 Server ( http://localhost ): IIS 7.5服务器( http:// localhost ):

  • User.Identity.Name: domain\\me User.Identity.Name:domain \\ me
  • Principal.WindowsIdentity.GetCurrent.Name: IIS APPPOOL\\Test.mysite.net Principal.WindowsIdentity.GetCurrent.Name:ISO APPPOOL \\ Test.mysite.net
  • Landing page: Runs 登陆页面:运行
  • Admin page: Runs 管理页面:运行
  • Enumerated roles: Shows roles (presumably) for IIS APPPOOL\\Test.mysite.net 枚举角色:显示IIS APPPOOL \\ Test.mysite.net的角色(可能)

IIS 7.5 Server (FQDN: http:// Test.mysite.net): Never-ending security challenge IIS 7.5服务器(FQDN:http:// Test.mysite.net):永无止境的安全挑战

Changing IIS Settings on the server 更改服务器上的IIS设置 在此输入图像描述

Both server sites return HTTP Error 500.24 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. 两个服务器站点都返回HTTP错误500.24 - 内部服务器错误检测到的ASP.NET设置不适用于集成管理管道模式。

Adding <identity impersonate="true"/> on dev machine: 在dev机器上添加<identity impersonate="true"/>

HTTP Error 500.24 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. HTTP错误500.24 - 内部服务器错误检测到的ASP.NET设置不适用于集成管理管道模式。

Most likely causes: • system.web/identity@impersonate is set to true. 最有可能的原因:•system.web/identity@impersonate设置为true。

Adding 添加

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>

with the impersonate above gives: 与上述模仿给出:

Dev Machine: (Same as first run) 开发机器:(与首次运行相同)

  • User.Identity.Name: domain\\me User.Identity.Name:domain \\ me
  • Principal.WindowsIdentity.GetCurrent.Name: domain\\me Principal.WindowsIdentity.GetCurrent.Name:domain \\ me
  • Landing page: Runs 登陆页面:运行
  • Admin page: Runs 管理页面:运行
  • Enumerated roles: All for me except admin roles 枚举角色:除管理员角色外,对我来说都是

IIS 7.5 Server (localhost): IIS 7.5服务器(localhost):

  • User.Identity.Name: domain\\me User.Identity.Name:domain \\ me
  • Principal.WindowsIdentity.GetCurrent.Name: domain\\me Principal.WindowsIdentity.GetCurrent.Name:domain \\ me
  • Landing page: Runs 登陆页面:运行
  • Admin page: Never-ending security challenge 管理页面:永无止境的安全挑战
  • Enumerated roles: Shows roles (presumably) for IIS APPPOOL\\Test.mysite.net 枚举角色:显示IIS APPPOOL \\ Test.mysite.net的角色(可能)

IIS 7.5 Server (FQDN: http:// Test.mysite.net): Never-ending security challenge IIS 7.5服务器(FQDN:http:// Test.mysite.net):永无止境的安全挑战

I've spent several hours combing through the posts here and elsewhere on Google. 我花了几个小时梳理这里和谷歌其他地方的帖子。 I don't know if this is a .Net 4.5+ thing or if I just missed something. 我不知道这是不是.Net 4.5+或者我错过了什么。 How can I get it to properly read the roles and authenticate to the folders? 如何让它正确读取角色并对文件夹进行身份验证?

And why when I try to get to the page using the full URL does it completely fail authentication? 为什么当我尝试使用完整的URL访问页面时,它完全失败了身份验证?

For 90% of this, it turns out the Active Directory server had an expired certificate, so refused to authenticate requests from the web server. 对于其中的90%,事实证明Active Directory服务器具有过期的证书,因此拒绝对来自Web服务器的请求进行身份验证。 Strangely, it did authenticate all the users signing in to the Windows accounts on the PC's. 奇怪的是,它确实验证了登录PC上Windows帐户的所有用户。 I'm posting this in case anyone else comes across a similar problem. 我发布这个以防万一其他人遇到类似的问题。 Though, I still can't figure out why on the server itself, navigating to the full URL still does not authenticate, but going to Localhost works just fine. 虽然,我仍然无法弄清楚为什么在服务器本身,导航到完整的URL仍然无法进行身份验证,但转到Localhost工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Windows身份验证模拟问题 - ASP.NET Windows Authentication Impersonate Problem ASP.NET Web API 2-&gt; Windows身份验证-&gt;在Azure上模拟Windows用户 - ASP.NET Web API 2 -> Windows Authentication -> Impersonate Windows user on Azure ASP.NET MVC 模拟不使用表单身份验证 - ASP.NET MVC Impersonate not working with Forms Authentication ASP.NET表单身份验证在本地主机服务器上进行身份验证,但不在Web服务器上进行身份验证 - ASP.NET Forms Authentication authenticates in localhost server, but not on the web server 使用Windows应用程序中的表单身份验证的ASP.NET Web服务 - ASP.NET web service using forms authentication from a windows app ASP.NET应用程序通过Windows身份验证或表单身份验证对Active Directory或SQL进行身份验证 - ASP.NET Application to authenticate to Active Directory or SQL via Windows Authentication or Forms Authentication ASP.NET表单身份验证和Windows身份验证 - ASP.NET Forms Authentication and Windows Authentication 表单身份验证 ASP.Net 失败 - forms authentication ASP.Net fails 如何使用基于PhoneGap的应用程序对ASP.NET Forms身份验证后端进行身份验证? - How to get a PhoneGap based app to authenticate against an ASP.NET Forms Authentication backend? ASP.NET 混合形式/Windows 身份验证 - ASP.NET Mixed Forms/Windows Authentication
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM