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

Announcements

News and Announcements icon
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
    23 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans