-1

我有带有 Windows 身份验证的 WCF Web 服务。

捆绑

<bindings>
  <netTcpBinding>
    <binding name="CommonWindowsBinding" maxReceivedMessageSize="40000000" >
      <security mode="Transport">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </netTcpBinding>

</bindings>

端点

    <endpoint address="Windows"
              binding="netTcpBinding" 
              bindingConfiguration="CommonWindowsBinding" 
              name="MyNameSpace.Contracts.ISimplePluginServiceWindows" 
              contract="MyNameSpace.Contracts.ISimplePluginService">
      <identity>
        <dns value="WCfServer" />
      </identity>
    </endpoint>

我想将其他信息传递给服务以进行此类身份验证(我通过检查 MS SQL Server 的用户和登录名来检查身份验证 - 我需要传递 mssql 服务器名称和数据库名称)。所以,我必须将一些自定义数据传递给验证器 => 我必须为 Windows 身份验证制作自定义验证器。我该怎么做?我找不到任何例子。

对于 UserName 身份验证,我可以使用继承 UserNamePasswordValidator 的 CustomUserNameValidator(通过登录传递服务器地址和数据库名称)来完成。

4

2 回答 2

1

Windows 身份验证是 Windows (EG Kerberos)。如果您想自己进行身份验证,请使用密码,但我认为它不会让您传递其他信息。你真的想将服务器地址和数据库名称传递给服务器吗?

选择凭证类型

于 2012-07-30T12:58:45.070 回答
0

我意识到,这通常是错误的方法。

  1. 我可以使用委托从 WCF 服务使用当前 Windows 用户的凭据对 MSSQL 服务器进行身份验证 - http://msdn.microsoft.com/en-en/library/ms730088.aspx

  2. 如果需要传递额外的数据(例如服务器名称和数据库名称),则应使用服务合同中的特殊方法执行此操作。

于 2012-08-03T14:31:09.050 回答