views:

180

answers:

1

Can i get the requester windows IPrincipal when he comsume WCF service?

+4  A: 

Using this code, you can examine the current security context inside your WCF service. If the user is authenticated, and the WindowsPrincipal is not null, then you're using a Windows security model - you can access all the relevant info:

        ServiceSecurityContext current = ServiceSecurityContext.Current;

        if (!current.IsAnonymous)
        {
            if (current.WindowsIdentity != null)
            {
                string userName = current.WindowsIdentity.Name;
            }
        }

Marc

marc_s
thanx a lot!i disable to mark this as answer somehow.Thank you anyway.Tamir
Tamir
Just what I needed
TWith2Sugars