Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find a WCF service caller's Active Directory domain username

Consider a WCF service using WsHttpBinding for which only the domain users are allowed to call this service.

How can you find the Active Directory username of the caller?

like image 698
Arian Avatar asked Feb 01 '11 10:02

Arian


2 Answers

Get the value of System.ServiceModel.ServiceSecurityContext.Current.WindowsIdentity.Name property.

It does not matter which binding you use as long as the security mode is different from None for the binding.

If the security mode is None then System.ServiceModel.ServiceSecurityContext.Current will be null.

like image 65
Rest Wing Avatar answered Oct 23 '22 11:10

Rest Wing


You can get identity of the user by calling:

ServiceSecurityContext.Current.WindowsIdentity.Name

or

OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name
like image 37
Ladislav Mrnka Avatar answered Oct 23 '22 10:10

Ladislav Mrnka