Search code examples
.netwcfauthentication

Get WindowsAccount for current user that made the request to the WCF service


Hi,

I got a WCF service(session) that uses both WindowsAuthentication and regular UserName/Password authentication.

Now I need to get the current user on the client that have sent the request to the WCF service.

I know that this can be done in IAuthorizationPolicy but Im not sure how to do this in a webmethod?

I have tried this :

WindowsIdentity.GetCurrent();

This does however only return the current user that runs the WCF service(it seems), not the client user that have med the current requst?

Pleas advice

BestRegards


Solution

  • ServiceSecurityContext.Current.WindowsIdentity should do the trick.