2011-10-28 9 views
6

私はWindows認証を使用するWebサービスを持っています。 WebサービスはIIS上でホストされます。そのWebサービスへのアクセスを特定のユーザーに限定することは可能ですか?私の現在のWeb構成:特定のユーザーのみIISでホストされているWCF Webサービスへのアクセスを許可する方法はありますか?

<services> 
    <service name="LANOS.SplunkSearchService.SplunkSearch"> 
    <endpoint binding="basicHttpBinding" bindingConfiguration="basicHttp" 
     contract="LANOS.SplunkSearchService.ISplunkSearch" /> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
</services> 

<bindings> 
    <basicHttpBinding> 
    <binding name="basicHttp" allowCookies="true" maxBufferSize="20000000" 
     maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"> 
     <readerQuotas maxDepth="32" maxStringContentLength="200000000" 
     maxArrayLength="200000000" /> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 

ところで、私は私がインターネット上で見つけこれと同様のソリューションを、試してみました:

<authentication mode="Windows"/> 

    <authorization> 

      <allow roles=".\Developers"/> 

      <allow users="DOMAIN\ServiceAccount"/> 

      <deny users="*"/> 

    </authorization> 

それは動作しません。しかし、。これは、すべてのドメインユーザーを通過させる:(

+0

あなたが無効になっています。 IISでWCFサービスをホストしているアプリケーションのWindows認証を有効にしていますか? –

+0

はい、私はそれをしました。 – neurotix

答えて

4

WROXのProfessional WCF 4はChの中にユーザー名/パスワード認証を設定するには8.要約する方法を説明し、カスタムバリデータが必要になります。。その後

public class MyCustomUserNamePasswordValidator : UserNamePasswordValidator 
{ 
    public override void Validate(string userName, string password) 
    { 
    if(userName != "foo" && password != "bar") 
    { 
     throw new SecurityTokenValidationException("Invalid user"); 
    } 
    } 
} 

ます「カスタム」にサービス設定であなたのuserNameAuthentication要素を変更し、バリデータを定義追加する必要があります。

<userNameAuthentication 
     userNamePasswordValidationMode = "Custom" 
      customUserNamePasswordValidatorType = 
      "Common.MyCustomUserNamePasswordValidator, Common" /> 

私はこのことができます願ってい

+1

Okey Illは試してみますが、実際にはWSコードを変更しなくても動作するようにはできません。私はまだそれがWebの設定を変更することによって動作するようになることを期待しています。 – neurotix

関連する問題