查找WCF服务调用方的Active Directory域用户名

Ari*_*ian 8 c# wcf wcf-security

考虑使用WsHttpBinding仅允许域用户调用此服务的WCF 服务.

如何找到呼叫者的Active Directory用户名?

Res*_*ing 14

获得System.ServiceModel.ServiceSecurityContext.Current.WindowsIdentity.Name财产的价值.

只要安全模式None与绑定不同,使用哪种绑定无关紧要.

如果安全模式None,然后System.ServiceModel.ServiceSecurityContext.Currentnull.


Lad*_*nka 9

您可以通过以下方式获取用户的身份:

ServiceSecurityContext.Current.WindowsIdentity.Name
Run Code Online (Sandbox Code Playgroud)

要么

OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name
Run Code Online (Sandbox Code Playgroud)