Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

How can we write C# code to deal with NTLM authentication with SSL support?

$
0
0

We get ‘the request failed with HTTP status 401: Unauthorized’ error when connect to Dynamics CRM 4.0 On-premise server by using CRM 4.0 SDK.   The server uses NTLM authentication with SSL support.  The following is our code:

string server = "https://xxx.xxx.com";

string userid = "xxx";

string password = "xxx";

CrmDiscoveryService discoveryService = new CrmDiscoveryService();

 

      discoveryService.UseDefaultCredentials = false;

      CredentialCache cache = new CredentialCache();

      cache.Add(new Uri(server), "NTLM", new NetworkCredential(userid, password, domain));

               discoveryService.Credentials = cache;

               discoveryService.Url = server + "/mscrmservices/2007/ad/crmdiscoveryservice.asmx";

 

RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();

               RetrieveOrganizationsResponse orgResponse = (RetrieveOrganizationsResponse)discoveryService.Execute(orgRequest);

 

 

foreach (OrganizationDetail orgDetail in orgResponse.OrganizationDetails)

{

    Console.WriteLine(orgDetail.OrganizationName.ToString());

}


Viewing all articles
Browse latest Browse all 82002

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>