2010-12-07 27 views
2

ロジスティクス: 1台のWCFサービスを実行しているサーバー。 1台のサーバーがWCFサービスのデータベースを実行しています。WCFサービスがクライアントを偽装していない

質問: 私はWCFサービスを1台のサーバーで実行しており、取得する必要のあるデータ用に別のサーバーに接続しています。私の問題は、クライアントマシンからサービスを呼び出すときに、 'NT AUTHORITY \ ANONYMOUS LOGON'というユーザのログインに失敗したというデータベースSQLエラーが発生することです。私は偽装を使用するWCFサービスを設定していると思います。

WCFサーバー設定:

<bindings> 
    <ws2007HttpBinding> 
    <binding maxReceivedMessageSize="214748"> 
     <security mode="Message"> 
     <transport clientCredentialType="Windows" 
        proxyCredentialType="Windows" realm="" /> 
     <message clientCredentialType="Windows" negotiateServiceCredential="true" 
       algorithmSuite="Default" establishSecurityContext="true" /> 
     </security> 
    </binding> 
    </ws2007HttpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="Host.ServiceBehavior" name="Wcf.MyWebService"> 
    <endpoint address="" behaviorConfiguration="" 
       binding="ws2007HttpBinding" contract="Wcf.MyWebServiceSoap"> 
     <identity> 
     <servicePrincipalName value="ServerMachineName" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" 
       contract="IMetadataExchange" /> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="Host.ServiceBehavior"> 
     <serviceMetadata httpsGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
     <serviceAuthorization impersonateCallerForAllOperations="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

WCFサービスコード:

public class MySebService: MyWebServiceSoap 
{ 
    [OperationBehavior(Impersonation = ImpersonationOption.Required)] 
    public string TestWebMethod() 
    { 
    DbDal dal = CreateDataAccessLayer(); 

    return dal.GetStringFromDatabase(); 
    } 
} 

クライアント設定とコード:

私はプログラム的に次の設定項目を設定しています:

public void TestWebMethod() 
{ 
    WS2007HttpBinding binding = new WS2007HttpBinding(); 
    EndpointAddress endpoint = new EndpointAddress("uri"); 
    ServiceClient client = new ServiceClient(binding, endpoint); 
    client.ClientCredentials.Windows.AllowedImpersonationLevel = 
           TokenImpersonationLevel.Impersonation; 
    client.ClientCredentials.Windows.AllowNtlm = true; 
    string result = client.TestWebMethod(); 
    client.Close(); 
} 

答えて

1

TokenImpersonationLevel.Impersonationは、サービスがローカルのリソースにアクセスすることを許可しますが、サービスが外部リソース(別のサービスなど)にアクセスすることを許可しません。

許可される偽装レベルを TokenImpersonationLevel.Delegationに設定する必要があります。

client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Delegation; 
+0

私は委任に変更しようとしていて、うまくいかなかったと思いました。しかし、私は再びそのショットを与えるでしょう。サービスとクライアントの設定項目が正しいかどうか – arc1880

+0

サービス側で、メソッドが呼び出されるときに来る偽装レベルを記録するコードをいくつか追加しました。クライアントでAllowedImpersonationLevelをDelegationに設定しましたが、ログには依然として偽装が設定されていることが示されています。私はまだデータベースにログインできません。 – arc1880

関連する問題