【问题标题】:WCF netTcpBinding Get UsernameWCF netTcpBinding 获取用户名
【发布时间】:2012-09-20 15:31:23
【问题描述】:

我有一个使用 netTcpBinding 的自托管 WCF 服务。是否有一个类可以用来访问调用该服务的客户端的域用户名。我尝试查看OperationContext,但无法弄清楚。谢谢

【问题讨论】:

    标签: .net wcf


    【解决方案1】:

    试试这个:

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

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

    【讨论】:

    • 谢谢,这就是我要找的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-12
    • 2010-10-08
    • 2011-04-24
    • 2011-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多