Click here to Skip to main content
15,885,811 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok, this may be a newbie question but what is the difference between these two?

WindowsIdentity.GetCurrent()
and
ServiceSecurityContext.Current()

Seems both of these return the client user id in a WCF service.
Posted
Updated 12-Feb-13 5:45am
v2

1 solution

The most common implementation in .NET to get authenticated Windows account under which process is running is to get via WindowsIdentity.GetCurrent()

WCF stores information about the identity of the remote client via System.ServiceModel.ServiceSecurityContext class. It’s two most important properties are:
- PrimaryIdentity – This is the identity used by the remote party for authentication while accessing the service.
- WindowsIdentity – This is the WindowsIdentity object representing the Windows Account information used for Windows Authentication.

We can access the ServiceSecurityContext instance from WCF service operation using the static Current property of ServiceSecurityContext class, i.e.: ServiceSecurityContext.Current

Thus, WindowsIdentity is at basic level and a part of identity when used via WCF.
For full details, refer: Identity & ServiceSecurityContext in WCF[^]
 
Share this answer
 
Comments
Espen Harlinn 12-Feb-13 14:42pm    
Very nice, Sandeep :-D
Sandeep Mewara 12-Feb-13 14:46pm    
Thanks Espen. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900