问题
I have a basic WCF service using basicHttpBinding. I have my site project and my services project. In my site project, I have a regular Services Reference to a service in my services project. In my development environment, it works fine. However, in our staging environment, we have enabled impersonation on the services application. This service connects to a SQL database using this user, of course.
The issue is, while the other ASMX services seem to impersonate just fine with the user defined in the web.config, the WCF service is still running as the site's user, causing SQL authentication to fail.
Are there extra steps to enable impersonation for my WCF service? I have not done anything special beside adding:
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
After I initialize my service proxy from my website. Thoughts? Thanks.
回答1:
If you mean ASP.NET impersonation account configured in web.config it doesn't work with WCF unless you turn on AspNetCompatibility. WCF doesn't offer any such configuration.
来源:https://stackoverflow.com/questions/5172840/wcf-service-not-impersonating-specified-user-in-config