WCF service authentication using System.Web.ApplicationServices.AuthenticationService, I can not authenticate membership provider

I am trying to authenticate using the authentication service and my membership provider. Ideally, I want to name my membership provider, but I bomb before I hit my provider. Says the token cannot be verified. Checking my error log, it looks like I'm trying to authenticate with Windows auth. This is not what I am going to do. This is a web file with an svc file. I use svcUtil and create a client from WSDL. I have a test page in the application from which I use the client. Its just a test page and will not be expanded. I see that Windows Integrated Authentication is checked in IIS, which does not seem to be correct, but if I remove it, Visual Studio will not debug it. In any case, I look in the event log and get two errors

Logon Failure:
 Reason:        Unknown user name or bad password
 User Name:    sandagtestuser
 Domain:        
 Logon Type:    8
 Logon Process:    Advapi  
 Authentication Package:    MICROSOFT_AUTHENTICATION_PACKAGE_V1_0
 Workstation Name:    SDD-CK

Logon attempt by: MICROSOFT_AUTHENTICATION_PACKAGE_V1_0
Logon account:  sandagtestuser
Source Workstation: SDD-CK
Error Code: 0xC0000064

web.config. , SSL HTTPS. WCF.

<system.serviceModel>
        <client>
        <endpoint address="https://SDD-CK/ATISServices/Services/AuthService.svc/AuthService"
              binding="basicHttpBinding" bindingConfiguration="userHttps_AuthenticationService"
              contract="AuthenticationService" name="userHttps_AuthenticationService" >
        </endpoint>
    </client>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <behaviors>
<serviceBehaviors>
              <behavior name="ATISServices.AuthServiceBehavior">
                <serviceMetadata httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>

            <binding name="userHttps_AuthenticationService" closeTimeout="00:01:00"
               openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
               allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
               maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
               messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
               useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="TransportWithMessageCredential">
                    <transport proxyCredentialType="None" clientCredentialType="None" realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />                       
                </security>
            </binding>
            <binding name="basic_auth_config">
                <security mode="TransportWithMessageCredential">
                    <message clientCredentialType="UserName" />
                </security>
            </binding>
        </basicHttpBinding>

    </bindings>
    <services>

        <service behaviorConfiguration="ATISServices.AuthServiceBehavior"
            name="System.Web.ApplicationServices.AuthenticationService">

            <endpoint binding="basicHttpBinding" bindingName="userHttps" bindingConfiguration="basic_auth_config"
                bindingNamespace="http://asp.net/ApplicationServices/v200"
                contract="System.Web.ApplicationServices.AuthenticationService"
                address="AuthService"/>

            <endpoint address="mex" binding="mexHttpsBinding" bindingConfiguration=""
                contract="IMetadataExchange" />  

        </service>
    </services>
</system.serviceModel>

, - WCF . , , . InnerException : At least one security token in the message could not be validated.

, web.config, .

 <system.web.extensions>
    <scripting>
        <webServices>
            <authenticationService enabled="true" requireSSL="true"/>
        </webServices>

    </scripting>
</system.web.extensions>

 <authentication mode="Forms" >
        <forms cookieless="UseCookies" />
    </authentication>

 <membership defaultProvider="KCMembershipProvider">
        <providers>
            <clear/>
            <add
            name="KCMembershipProvider"
            applicationName="/"
            type="zcore.MembershipProvider.KCMembershipProvider, zcore.MembershipProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"  />
        </providers>
    </membership>

. . . "makecert". , - "localhost", . httpcfg cert 9307, , ": 9307" , . .

Cheers,
~ ck -

+3
1

. .

 <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="KCMembershipProvider"/>
      </serviceCredentials>
+1

Source: https://habr.com/ru/post/1765206/


All Articles