質問

基本的なHTTP認証モードを使用するWebHTTPBindingサービスは、Windowsアカウントに対して提供されたユーザー名/パスワードを検証し、UserNamePasswordValidationMode="MemberipProvider"を指定しました。

この問題を報告する他の投稿も見つけましたが、この状況への回答は与えられていません。

  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="WebBinding">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Basic" />
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="EPWeb">
          <webHttp helpEnabled="true" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="SqlProvider" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="Foo">
        <endpoint address="Test" behaviorConfiguration="EPWeb"
            binding="webHttpBinding" bindingConfiguration="WebBinding"
            contract="Foo.IService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:3456/" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
.

役に立ちましたか?

解決

This configuration will not work. But there are workarounds to this issue:

  • Create Login() method and use authentication token, which you pass to every service method.
  • Use custom validation mode, and validate username\password by code, using Membership.ValidateUser()

他のヒント

Token passed login or a custom http authentication module.

Here is a link to a custom authentication module. http://custombasicauth.codeplex.com/

For token based, you could use an OAuth implementation.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top