Pregunta

Tengo un servicio de WebHTTPBinding que utiliza el modo de autenticación HTTP básico, sin embargo, por alguna razón extraña, valida proporcionada proporcionada nombre de usuario / contraseña contra las cuentas de Windows, pensé que especifiqué el nombre de usuario: "MembreshipProvider".

Encontré otros mensajes que también reportan este problema, pero no se han dado ninguna respuesta a esta situación.

  <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>

¿Fue útil?

Solución

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()

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top