2

次の構成のWCFサービスがあります

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
   <compilation debug="true" />
</system.web>

<system.serviceModel>
<bindings>
  <netTcpBinding>
    <binding name="CommonWindowsBinding" maxReceivedMessageSize="40000000">
      <security mode="TransportWithMessageCredential" >
        <transport clientCredentialType="None"/>
        <message clientCredentialType="Windows" />
      </security>
    </binding>
  </netTcpBinding>
</bindings>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

<services>
  <service behaviorConfiguration="CommonBehavior" name="Megatec.MasterTourService.AdminService">
    <endpoint address="Windows" binding="netTcpBinding" bindingConfiguration="CommonWindowsBinding" name="Megatec.MasterTourService.Contracts.IAdminServiceWindows" contract="Megatec.MasterTourService.Contracts.IAdminService">
      <identity>
        <dns value="WCFServer" />
      </identity>
    </endpoint>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="CommonBehavior">
      <dataContractSerializer maxItemsInObjectGraph="10000000" />
      <serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceAuthorization impersonateCallerForAllOperations="true" />
      <serviceCredentials>

        <clientCertificate>
          <authentication certificateValidationMode="PeerTrust" />
        </clientCertificate>

        <serviceCertificate findValue="WCFServer" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />

        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Megatec.MasterTourService.Security.CustomUserNameValidator, Megatec.MasterTourService.Security" />
        </serviceCredentials>
       </behavior>
     </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

コード

public class AdminService : BaseAuthService, IAdminService
{
    [OperationBehavior(Impersonation = ImpersonationOption.Required)]
    public bool HasRole(string roleName)
    {
        //work with database
    }
}

このサービスはIIS7でホストし、アプリケーションプール用にドメインユーザー(Master \ MyLogin)を設定しました。委任にはドメインユーザーが必要です(手順4による)。

ローカルクライアント(同じコンピューター、Master \ MyLoginまたは他のドメインユーザーの下)からサービスを利用する場合は、正常に機能します。しかし、他のネットワークコンピュータからサービスを利用しようとすると、失敗しました。ApplicationPoolIdentityではすべてが正常に機能します。

Master \ MyLoginは、サービスを提供しているコンピューターの管理者です(ただし、ドメイン管理者ではありません)。

たぶん、Master \ MyLoginに付与されるべき権利がありますか?

更新します。クライアント例外。

最初は、SecurityNegotiationExceptionがありました。次に、セクションを追加しました

<identity>
    <userPrincipalName value="myLogin@Mydomain" />
</identity>

新しい例外はMessageSecurityExceptionでした。

The identity check failed for the outgoing message. The expected identity is "identity(http://schemas.xmlsoap.org/ws/2005/05/identity/right/possessproperty: http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn)" for the 'net.tcp://dev4-10:5012/IISTest/AdminService.svc/Windows' target endpoint.

<identity>クライアントとサービスをどのように構成する必要がありますか?

4

2 に答える 2

2

残念ながら、Transport/TransportWithMessageCredential セキュリティ モードは、クライアント資格情報を使用したそのような作業をサポートしていません。私はCommonWindowsBinding次のように変更しました

    <binding name="CommonWindowsBinding" maxReceivedMessageSize="40000000">
      <security mode="Message">
        <message clientCredentialType="Windows" />
      </security>
    </binding>
于 2012-10-30T13:04:38.617 に答える
1

Transport だけでなく、TransportWithMessageCredential を使用する必要があると思います。を使用するだけでサービスが HTTPS 経由で動作しますが、認証に資格情報を使用することとは関係ありません。

使用する場合は、HTTPS を使用でき、ユーザー名とパスワードを使用できます。

MSDN の記事

本当にトランスポートを使用したい場合は、サービス構成からノードを取り出してください。

于 2012-10-30T08:21:55.497 に答える