简体   繁体   中英

Authenticate User using Windows Authentication in REST WCF Web API

I have a requirement to expose some WCF Web API to a 3rd party system. The 3rd party system may validate the users using Windows Authentication. My Web service will expose a Login method where the username is passed in. I need to authenticate the passed in user using Windows Authentication.

I try to determine the role for the user by using:

 Roles.GetRolesForUser(UserID)

I get the following error message: "Method is only supported if the user name parameter matches the user name in the current Windows Identity. "

How do I validate a passed in username using Windows Authentication?

You have to impersonate the user first, before you can get his/her roles. Or be a user that has sufficient access privileges anyway.

This is a good reference from Microsoft that explains it all:

http://msdn.microsoft.com/en-us/library/ff647405.aspx

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