Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: WCF
Ok, this may be a newbie question but what is the difference between these two?
Seems both of these return the client user id in a WCF service.
Posted 11-Feb-13 14:30pm
Edited 12-Feb-13 6:45am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^]
Espen Harlinn at 12-Feb-13 14:42pm
Very nice, Sandeep :-D
Sandeep Mewara at 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)

  Print Answers RSS
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 419
2 OriginalGriff 360
3 CHill60 310
4 CPallini 275
0 Sergey Alexandrovich Kryukov 10,017
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076

Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100