如果应用程序池是本地系统,而不是IIS 7中的networking服务,则受约束的委派会起作用

我在Windows Server 2008上遇到了约束委派和IIS 7问题。

我们有一个使用模拟来访问SQL Report Server的Web应用程序。 这与IIS 6一起工作良好,可信委托和委托授权。 但是我们遇到了IIS 7的问题。

我已经能够得到它是这样的,在IIS 7上,应用程序池作为NetworkService运行,并configuration了约束委派,我们从报表服务器得到一个HTTP 401 Unauthorized错误,应用程序池作为本地系统运行模仿工作正常。

我已经在Classic和Integrated Pipeline中进行了testing。 下面是一个模拟此问题的非常简单的testing页面中的代码。 从Windows 2003的IIS 6服务器运行相同的testing页面正常工作。 任何想法的安全策略,IISconfiguration,甚至服务器function和angular色,可能会影响这?

请注意我已经检查了Kerberos工作正常,并且受约束的委托configuration是正确的。

private void testImpersonation() { string url = "http://testsvr7/reportserver/"; System.Security.Principal.WindowsIdentity user = (System.Security.Principal.WindowsIdentity)Context.User.Identity; System.Security.Principal.WindowsImpersonationContext WICTX = null; StringBuilder results = new StringBuilder(); try { if (user != null) { WICTX = user.Impersonate(); results.AppendFormat("<br />Impersonating, user: {0}", System.Security.Principal.WindowsIdentity.GetCurrent().Name); System.Net.HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); // Assign the credentials of the user being impersonated. myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials; System.Net.HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); results.AppendFormat("<br />Authentication successful - {0}, {1}", url, CredentialCache.DefaultCredentials); } } catch (Exception ex) { results.AppendFormat("<br />Exception: {0}", ex.Message); } finally { if (WICTX != null) WICTX.Undo(); } Response.Write(results.ToString()); 

我相信我已经find了解决scheme – 如果我将useAppPoolCredentials属性的system.webServer / security / authentication / windowsAuthentication设置为“true”,那么带有NetworkService的AppPool在约束委托下工作正常。

在Windows Server 2008和2008 R2上进行了testing。

我不确定这是为什么,而且我确实很难弄清楚这个设置是什么,以及它会如何影响这种情况。 您可以通过IISpipe理器中的configuration编辑器为2008 R2上的IIS设置此值。
或者使用下面的命令(唯一的办法,我发现这样做的2008(不是R2)):

 %windir%\system32\inetsrv\appcmd set config "Default Web Site/MyApplication" /section:system.webServer/security/authentication/windowsAuthentication /useAppPoolCredentials:true /commit:MACHINE/WEBROOT/APPHOST