Tuesday, 31 July 2012

How do I authenticate a console application with a WCF web service using NTLM?


  1. <security mode="TransportCredentialOnly">
  2.     <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
  3. </security>
  4.        
  5. public static WMServiceClient CreateWMServiceProxy()
  6. {
  7.     var proxy = new WMServiceClient();
  8.  
  9.     proxy.Endpoint.Address = new EndpointAddress( ConfigurationCache.WMServiceEndpoint );
  10.     proxy.Endpoint.Binding = new BasicHttpBinding( BasicHttpSecurityMode.TransportCredentialOnly )
  11.     {
  12.         MaxBufferSize = 2147483647,
  13.         MaxReceivedMessageSize = 2147483647
  14.     };
  15.  
  16.     ( (BasicHttpBinding) proxy.Endpoint.Binding ).Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
  17.  
  18.     return proxy;
  19. }

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Popular Posts