Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个使用 netTcpBinding 的自托管 WCF 服务。是否有一个类可以用来访问调用该服务的客户端的域用户名。我尝试查看OperationContext但无法弄清楚。谢谢
OperationContext
试试这个:
ServiceSecurityContext serviceSecurityContext = ServiceSecurityContext.Current; if (serviceSecurityContext != null) { string accountText = serviceSecurityContext.WindowsIdentity.Name; }
WindowsIdentity 属性包含大量有关用户的信息。