Impersonation in ASP.NET web application does not work when running on IIS

怎甘沉沦 提交于 2019-11-30 15:37:45

I found the answer here:

http://support.microsoft.com/kb/810572

"Kerberos does not work in a load-balanced architecture and IIS drops back to NTLM authentication. Because you cannot use NTLM for delegation, any applications or services that require delegation do not work. For more information, click the following article number to view the article in the Microsoft"

And that was exactly the case. I tried now with another machine that is not load-balanced and it works.

The only thing that still surprises me is that ImpersonationLevel of the identity is still Impersonate not Delegate...

After setting <identity impersonate="true"/> in your web.config try the following:

using (((WindowsIdentity)User.Identity).Impersonate())
using (var client = new WebClient { Credentials = CredentialCache.DefaultNetworkCredentials })
{
    string result = client.DownloadString("http://sharepoint");
}

you need to configure your site correctly in IIS for impersonation to work.

see Configure ASP.NET Impersonation Authentication (IIS 7)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!