Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net WCF netTcpBinding获取用户名_.net_Wcf - Fatal编程技术网

.net WCF netTcpBinding获取用户名

.net WCF netTcpBinding获取用户名,.net,wcf,.net,Wcf,我有一个使用netTcpBinding的自托管WCF服务。是否有一个类可用于访问调用服务的客户端的域用户名。我试图查看操作上下文,但没有找到答案。谢谢试试这个: ServiceSecurityContext serviceSecurityContext = ServiceSecurityContext.Current; if (serviceSecurityContext != null) { string accountText = serviceSecurityContext.Windo

我有一个使用netTcpBinding的自托管WCF服务。是否有一个类可用于访问调用服务的客户端的域用户名。我试图查看
操作上下文
,但没有找到答案。谢谢

试试这个:

ServiceSecurityContext serviceSecurityContext = ServiceSecurityContext.Current;
if (serviceSecurityContext != null)
{
  string accountText = serviceSecurityContext.WindowsIdentity.Name;
}
WindowsIdentity属性包含大量有关用户的信息。

请尝试以下操作:

ServiceSecurityContext serviceSecurityContext = ServiceSecurityContext.Current;
if (serviceSecurityContext != null)
{
  string accountText = serviceSecurityContext.WindowsIdentity.Name;
}

WindowsIdentity属性包含大量有关用户的信息。

谢谢,这是我一直在寻找的Hanks,这是我一直在寻找的