You must Sign In to post a response.
  • Category: WCF

    Wcf security using membersship provider

    we are getting below error after implementing membership provider security in wcf

    System.IdentityModel.Tokens.SecurityTokenValidationException: Authentication of a username/password using SqlMembershipProvider failed

    Please help
  • #765875
    This may happen due to wrong user name and password, assign defaultProvider="SqlMembershipProvider" then WCF application will use SQL username and password.
    checkout below link for more details
    http://www.codewrecks.com/blog/index.php/2009/09/08/use-aspnet-membership-provider-with-a-wcf-svc-service/

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766719
    HI,

    Kindly use the following code. It will help you lot

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.serviceModel>
    <services>
    <service behaviorConfiguration="MyServiceBehavior" name="Microsoft.Samples.GettingStarted.CalculatorService">
    <endpoint address="http://microsoft.com/WCFservices/Calculator"
    binding="wsHttpBinding" bindingConfiguration="MembershipBinding"
    name="ASPmemberUserName" contract="Microsoft.Samples.GettingStarted.ICalculator" />
    </service>
    </services>
    <behaviors>
    <serviceBehaviors>
    <behavior name="MyServiceBehavior">
    <serviceCredentials>
    <userNameAuthentication
    userNamePasswordValidationMode="MembershipProvider"
    membershipProviderName="SqlMembershipProvider" />
    </serviceCredentials>
    </behavior>
    </serviceBehaviors>
    </behaviors>
    <bindings>
    <wsHttpBinding>
    <binding name="MembershipBinding">
    <security mode="Message">
    <message clientCredentialType="UserName" />
    </security>
    </binding>
    </wsHttpBinding>
    </bindings>
    </system.serviceModel>
    </configuration>

  • #766720
    Hi,,

    Use the following code
    <Code>
    <behaviors>
    <serviceBehaviors>
    <behavior name="MyServiceBehavior">
    <serviceCredentials>
    <userNameAuthentication
    userNamePasswordValidationMode="MembershipProvider"
    membershipProviderName="SqlMembershipProvider" />
    </serviceCredentials>
    </behavior>
    </serviceBehaviors>
    </behaviors>

    </Code>


Sign In to post your comments