Как вызвать аутентификацию WCF windows из WPF
BasicHttpBinding Funct_LocalBinding = new BasicHttpBinding(); EndpointAddress Funct_LocalEndpoint = new EndpointAddress("http://172.16.50.149:1546/BTA_Service.svc"); Funct_LocalBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; Funct_LocalBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; Funct_LocalBinding.Security.Transport.ProxyCredentialType=HttpProxyCredentialType.None; Funct_LocalBinding.Security.Transport.Realm=""; Funct_LocalBinding.Security.Message.ClientCredentialType=BasicHttpMessageCredentialType.UserName; Funct_LocalBinding.Security.Message.AlgorithmSuite=SecurityAlgorithmSuite.Default; BTA_ServiceClient serverObject = new BTA_ServiceClient(Funct_LocalBinding, Funct_LocalEndpoint); serverObject.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; serverObject.ClientCredentials.Windows.AllowNtlm = true; serverObject.ClientCredentials.UseIdentityConfiguration = true; serverObject.ClientCredentials.Windows.AllowedImpersonationLevel =System.Security.Principal.TokenImpersonationLevel.Impersonation; var str = serverObject.FlightCode_Validation(new PNRModel() { Flight_Code = "AA", RequestId = "4" } );
ошибка:
{"HTTP-запрос не прошел проверку схемы проверки подлинности клиента 'переговоры'. Заголовок аутентификации, полученный от сервера, был "Negotiate, NTLM"."}
Что я уже пробовал:
Моя конфигурация службы Wcf
<?xml version="1.0"?> <configuration> <appSettings> <add key="InfiServiceUrl" value="http://172.16.50.146:1717/InfiService.svc/BTAValidation"/> <add key="Islogging" value="Y"/> <add key="LogFilePath" value="C:\BTA_Exception\Log\"/> </appSettings> <!-- For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367. The following attributes can be set on the <httpRuntime> tag. <system.Web> <httpRuntime targetFramework="4.5" /> </system.Web> --> <system.web> <compilation debug="true" targetFramework="4.5"/> <pages controlRenderingCompatibilityVersion="4.0"/> </system.web> <connectionStrings> <add name="GDS_Connection" connectionString="F5XGWMkZIKnvmeKRLmDIs85gfShEhVsCb31D96JcpdLpltZWV3RBdpfwwCVPeOPz5EcrGS0/6c2N/s3sV9TIiNokGMnzuptigq6kJQHbpAWo6G0mBWlIag=="/> </connectionStrings> <system.serviceModel> <services> <service name="BTA_WCF_Service.BTA_Service"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="BTA_WCF_Service.IBTA_Service"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <bindings> <basicHttpBinding> <binding name="TransportSecurity"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows"/> </security> </binding> </basicHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="True"/> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <directoryBrowse enabled="true"/> </system.webServer> </configuration>