简体   繁体   中英

Using both OWIN Cookie Authentication and Windows Authentication in the same MVC application

When I use OWIN authentication out-of-the-box the Request.LogonUserIdentity on the AccountController are always the IIS user the site is deployed to instead of the user who actually made the request. This is with both Anonymous and Windows auth enabled on the server. If I turn Anonymous access off the Request.LogonUserIdentity is the one I expect.

What I want to do, based on a database setting, is perform a Windows login against a third-party system on that same server, which means that I need to impersonate the user making the HTTP Request, but I also need the option to allow Anonymous login. But because that user is ALWAYS the IIS user this doesn't work. Is there some way I can access the actual user making the request at this point in the authentication process? Or do I need to implement some type of handler to preprocess the raw requests?

I have no idea where to begin. Any help pushing in the right direction would be very helpful.

我能够使用这个项目https://github.com/MohammadYounes/MVC5-MixedAuth中的技术拼凑出相当不错的实现。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM