【问题标题】:W3C (IIS) logging does not log the ClaimsIdentity username of my WCF serviceW3C (IIS) 日志不会记录我的 WCF 服务的 ClaimsIdentity 用户名
【发布时间】:2016-02-03 07:22:08
【问题描述】:

我的前端 Web 应用程序 (MVC) 使用不记名密钥 (SAML) 向 WCF 后端服务验证自己。身份验证工作正常,并且正确设置了 ClaimsIdentity 对象。但是,ClaimsIdentity 的用户名不会出现在 W3C IIS 日志记录中。在前端,用户名是(IIS W3C)日志记录的一部分,它不会出现在 WCF 服务上。

前端日志记录:

2016-02-02 16:10:24 xxx.xxx.xxx.xxx POST /mobile/Tasks/Tasks/ 443 Wit.329406069 xxx.xxx.xxx.xxx Mozilla/5.0+ (Windows+NT+6.1;+WOW64;+Trident/7.0;+BOIE9;NLNL;+rv:11.0)+like+Gecko 200 0 0 597 17504 937

后端日志记录:

2016-02-02 16:10:24 xxx.xxx.xxx.xxx POST /services/TaskService.svc - 443 - xxx.xxx.xxx.xxx - 200 0 0 1118 9239 765

后端日志中缺少用户名。

这是我使用的绑定:

<ws2007FederationHttpBinding>
<binding>
  <security mode="TransportWithMessageCredential">
    <message issuedKeyType="BearerKey" establishSecurityContext="false">
      <tokenRequestParameters>
        <trust:SecondaryParameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
          <trust:KeyType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer</trust:KeyType>
          <trust:SecondaryParameters xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
            <trust:KeyType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer</trust:KeyType>
            <trust:CanonicalizationAlgorithm>http://www.w3.org/2001/10/xml-exc-c14n#</trust:CanonicalizationAlgorithm>
            <trust:EncryptionAlgorithm>http://www.w3.org/2001/04/xmlenc#aes256-cbc</trust:EncryptionAlgorithm>
          </trust:SecondaryParameters>
        </trust:SecondaryParameters>
      </tokenRequestParameters>
    </message>
  </security>
</binding>

【问题讨论】:

    标签: c# asp.net wcf iis


    【解决方案1】:

    IIS 仅在使用 Windows/基本(和其他一些)身份验证方法时才能记录用户名。

    在您的情况下,IIS 使用匿名身份验证,您的应用程序处理真正的检查。因此,IIS 不记录任何内容,您必须使用自己的日志记录来跟踪用户。

    【讨论】:

    • 有什么方法可以让 IIS 记录用户名?
    • @KeesdeWit 没有。这是不可能的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多