W3C (IIS) 日志记录不会记录我的 WCF 服务的 ClaimIdentity 用户名

本文关键字:记录 服务 WCF ClaimIdentity 用户 我的 IIS 日志 W3C | 更新日期: 2023-09-27 18:33:03

我的前端 Web 应用程序 (MVC) 使用持有者密钥 (SAML) 向 WCF 后端服务器验证自身。身份验证工作正常,并且正确设置了声明标识对象。但是,ClaimIdentity 的用户名不会出现在 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>

W3C (IIS) 日志记录不会记录我的 WCF 服务的 ClaimIdentity 用户名

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

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