I have a ASP.NET MVC 5 site that uses forms authentication via a custom membership class.
My site's login procedure:
An anonymous visitor tries to navigate to my site. He's allowed to do so, but is redirected to my login page.
The visitor keys his username and password, configured in my network's active directory (AD).
- .NET AD code validates the credential, then responds with a cookie for the visitor containing basic info (his name, email address, etc).
- The visitor is redirected to the home page. He's authenticated, but the site is actually running as its app pool identity, not the logged in user's AD identity.
My problem: In #4, how do I make my site's identity run as the authenticated user's AD identity, instead of the site's app pool identity? I need to do this because a certain service my app consumes requires the AD user's identity, not the app pool's identity.
Possible solution: In #2, I'm getting the vistor's username and password and using it to authenticate he is a valid AD identity. I could encrypt and save the user's password, then whenever I need to use the service which requires the user's AD identity, I could just create a new NetworkCredential from his username and password. I don't like this solution though, because I'd rather not store the user's password, if I can avoid it.
Thanks for any help!