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
从WCF服务中访问ServiceSecurityContext.Current.PrimaryIdentity.Name_Wcf - Fatal编程技术网

从WCF服务中访问ServiceSecurityContext.Current.PrimaryIdentity.Name

从WCF服务中访问ServiceSecurityContext.Current.PrimaryIdentity.Name,wcf,Wcf,我对WCF非常陌生,但我已经彻底搜索了这个主题,还没有找到满意的答案,所以我的问题是: 在我的WCF服务中,我需要访问用户的用户名。从我读到的所有内容中,我应该能够从ServiceSecurityContext.Current.PrimaryIdentity.Name中获得这些信息。然而,它并没有像我希望的那样返回Domain\Username,而是始终返回NT AUTHORITY\NETWORK SERVICE。如何获取登录到访问我的服务的计算机的个人的实际域和用户名 谢谢。你看过这门课了吗

我对WCF非常陌生,但我已经彻底搜索了这个主题,还没有找到满意的答案,所以我的问题是:

在我的WCF服务中,我需要访问用户的用户名。从我读到的所有内容中,我应该能够从ServiceSecurityContext.Current.PrimaryIdentity.Name中获得这些信息。然而,它并没有像我希望的那样返回Domain\Username,而是始终返回NT AUTHORITY\NETWORK SERVICE。如何获取登录到访问我的服务的计算机的个人的实际域和用户名

谢谢。

你看过这门课了吗

表示远程参与方的安全上下文。在客户方面, 表示服务标识,在服务上表示 客户身份

e、 g

…确保您已将服务设置为通过Windows安全性进行身份验证。

您看过该类吗

表示远程参与方的安全上下文。在客户方面, 表示服务标识,在服务上表示 客户身份

e、 g


…确保已将服务设置为通过Windows安全性进行身份验证。

要使用Windows凭据,请将clientCredentialType设置为“Windows”。在局域网内使用wsHttpBinding或netTcpBinding

    <bindings>
  <netTcpBinding>
    <binding name="WindowsCredentials">
      <security mode="Transport">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>

要使用Windows凭据,请将clientCredentialType设置为“Windows”。在局域网内使用wsHttpBinding或netTcpBinding

    <bindings>
  <netTcpBinding>
    <binding name="WindowsCredentials">
      <security mode="Transport">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>


Lingaraj-按照您的建议尝试wsHttpBinding和netTcpBinding。无论哪种方式,当我查看ServiceSecurityContext.Current.PrimaryIdentity.Name或ServiceSecurityContext.Current.WindowsIdentity.Name时,我仍然获得NT AUTHORITY\NETWORK服务。为了澄清,我试图做的是允许每个人都访问我的WCF服务,然后在用户进入该服务后,确定该用户是否经过身份验证(Windows Auth),并返回该用户所属的组。为此,我需要访问用户的实际域和username.Lingaraj-正如您建议的那样,使用wsHttpBinding和netTcpBinding进行了尝试。无论哪种方式,当我查看ServiceSecurityContext.Current.PrimaryIdentity.Name或ServiceSecurityContext.Current.WindowsIdentity.Name时,我仍然获得NT AUTHORITY\NETWORK服务。为了澄清,我试图做的是允许每个人都访问我的WCF服务,然后在用户进入该服务后,确定该用户是否经过身份验证(Windows Auth),并返回该用户所属的组。为此,我需要访问用户的实际域和用户名。