Guest User

Untitled

a guest
Dec 14th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'Negotiate, NTLM'.
  2.  
  3. <system.serviceModel>
  4. <client />
  5. <behaviors>
  6. <serviceBehaviors>
  7. <behavior name="authBehavior">
  8. <serviceAuthorization principalPermissionMode="UseWindowsGroups">
  9. <authorizationPolicies>
  10. <add policyType="WCF.AuthorizationPolicy, WCF" />
  11. </authorizationPolicies>
  12. </serviceAuthorization>
  13. <serviceCredentials>
  14. <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCF.IdentityValidator, WCF" />
  15. <serviceCertificate findValue="16E86CCAFFE6211DAE6E841B984F71FB7609D349" storeLocation="LocalMachine" x509FindType="FindBySerialNumber" storeName="My" />
  16. </serviceCredentials>
  17. <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
  18. <serviceDebug includeExceptionDetailInFaults="true" />
  19. </behavior>
  20. </serviceBehaviors>
  21. </behaviors>
  22. <bindings>
  23. <basicHttpsBinding>
  24. <binding name="basicHttpsEndpointBinding" maxReceivedMessageSize="1073741824" maxBufferSize="1073741824" maxBufferPoolSize="1073741824">
  25. <readerQuotas maxDepth="32" maxArrayLength="1073741824" maxStringContentLength="1073741824" />
  26. <security mode="Transport">
  27. <transport clientCredentialType="Ntlm" />
  28. </security>
  29. </binding>
  30. </basicHttpsBinding>
  31. </bindings>
  32. <services>
  33. <service name="WCF.MyService" behaviorConfiguration="authBehavior">
  34. <endpoint address="" binding="basicHttpsBinding" bindingConfiguration="basicHttpsEndpointBinding" contract="WCF.IMyService">
  35. <identity>
  36. <dns value="example.com" />
  37. </identity>
  38. </endpoint>
  39. <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  40. </service>
  41. </services>
  42.  
  43. BasicHttpsBinding binding = new BasicHttpsBinding
  44. {
  45. MaxBufferPoolSize = 1073741824,
  46. MaxBufferSize = 1073741824,
  47. MaxReceivedMessageSize = 1073741824
  48. };
  49. binding.ReaderQuotas.MaxDepth = 32;
  50. binding.ReaderQuotas.MaxArrayLength = 1073741824;
  51. binding.ReaderQuotas.MaxStringContentLength = 1073741824;
  52. binding.Security.Mode = BasicHttpsSecurityMode.Transport;
  53. binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
  54.  
  55. MyServiceClient client = new MyServiceClient(binding, new EndpointAddress(new Uri("https://example.com/MyService.svc"), new DnsEndpointIdentity("mydomain.com")));
  56. client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
  57.  
  58. client.ClientCredentials.Windows.ClientCredential.Domain = Configuration.GetSection("WCF")["MyServiceDomain"];
  59. client.ClientCredentials.Windows.ClientCredential.UserName = Configuration.GetSection("WCF")["MyServiceUserName"];
  60. client.ClientCredentials.Windows.ClientCredential.Password = Configuration.GetSection("WCF")["MyServicePassword"];
  61.  
  62. // client call
Add Comment
Please, Sign In to add comment