web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

SOAP request with windows authentication issue

(0) ShareShare
ReportReport
Posted on by 80

Hi, 

I am facing an issue to execute SOAP request from MS CRM plugin. Its a integration with Biz Talk. Earlier i was able to execute same with Anonymous auth but now they turned it to windows auth, and I am not able to consume it, it gave me error ‘The remote server returned an error: (401) Unauthorized.’ 

Here is my code

//System.Net.WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Proxy.Credentials = CredentialCache.DefaultCredentials;

this above part works fine for anonymous setting. 

For Windows auth i tried following code 

1. HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;

2. HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Proxy.Credentials = new NetworkCredential("Ser-BDL-CRM_Dev", "uT5fzuYg", "AMERICA");

3. HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
CredentialCache cc = new CredentialCache();
cc.Add(
new Uri(url),
"NTLM",
new NetworkCredential("Ser-BDL-CRM_Dev", "uT5fzuYg", "AMERICA"));
webRequest.Proxy.Credentials = cc;

 Any help will appreciated.

Thanks.  

*This post is locked for comments

I have the same question (0)
  • ScottDurow Profile Picture
    21 on at

    Hi,

    1. Make sure your plugin isn't sandboxed (because you can't use windows auth in a sandboxed plugin)

    2. If you are using Default Network Credentials then the service account that is running CRM will need to be enabled for delegated kerberos authentication because of the 'double hop'

    3. If you are sending username and password then your code number 3 should work provided that the Webservice that is being called has this user given permissions in IIS.

  • Verified answer
    CRM-guy Profile Picture
    80 on at

    Thanks Scott.

    Plugin is not running in Sandbox mode.

    I used following approach and it worked out .. but still i don't understand why it wont worked for 'HttpWebRequest' but worked with 'BasicHttpBinding'  (for BasicHttpBinding i created proxyClass using svc.util)

    BasicHttpBinding basichttpBinding = new BasicHttpBinding();

               basichttpBinding.Name = "BasicHttpBinding_IPOCService";

               basichttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;

               basichttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;

               EndpointAddress endPointAddress = new EndpointAddress(url);

               DocProdServicesClient client = new DocProdServicesClient(basichttpBinding, endPointAddress);

               client.ClientCredentials.Windows.ClientCredential.Domain = "***********";

               client.ClientCredentials.Windows.ClientCredential.UserName = "***********";

               client.ClientCredentials.Windows.ClientCredential.Password = "********";

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans