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?
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
.
You can get identity of the user by calling:
ServiceSecurityContext.Current.WindowsIdentity.Name
or
OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With