从WCF请求中检索域名

时间:2015-02-12 06:56:36

标签: c# wcf

我使用以下代码从WCF操作上下文中检索域名。

WindowsIdentity identity = OperationContext.Current.IncomingMessageProperties.Security.ServiceSecurityContext.WindowsIdentity;
domain = identity.Name.Split('\\')[0];

当我部署生成的域名时,我在我的机器中按预期工作总是作为NT AUTHORITY。

部署服务器运行Windows Server 2008 R2和IIS 7.我使用basicHttpBinding,以下是绑定配置。任何人都可以指出我做错的事吗?

<basicHttpBinding>
        <binding name="BasicHttpBinding_IIdentityService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="Transport">
            <transport clientCredentialType="Ntlm" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>

0 个答案:

没有答案