Set credentials on a WebService connection

Assuming that si is a SoapHttpClientProtocol instance, this is how set the credentials:

si.Credentials = CredentialCache.DefaultCredentials;

(If the client is a web application then impersonation must be enabled.)

or

NetworkCredential myCred = 
    new NetworkCredential(username, password, domainName); 
CredentialCache myCache = new CredentialCache(); 
myCache.Add(new Uri(si.Url), "NTLM", myCred); 
si.Credentials = myCache; 
si.UnsafeAuthenticatedConnectionSharing = true;
si.ConnectionGroupName = username;

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.