Thursday, 12 November 2009

WCF Fix-The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'NTLM'.

I thought I'd done a post on this error previously, but I double checked google and I obviously hadn't.

The Problem
When calling WSS / SharePoint web services (such as Lists.asmx) via WCF, you will normally get this error if you leave the settings as configured by the “Add Service Reference Wizard” :

“The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'NTLM'.”

The Solution

You must specify a non-anonymous impersonation level for your ClientCredentials. Just specifying a username and password for your WCF Service reference's ClientCredentials.UserName.UserName and ClientCredentials.UserName.Password is not sufficient to resolve the problem.

In particular (When SharePoint server is on different domain):

ServiceReference1.ListsSoapClient client = new ServiceReference1.ListsSoapClient();
client.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("username", "password", "domain");
client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Identification;
client.GetListCollection();


Of course, when on same domain, don’t have to pass in the Windows.ClientCredential information. You can also set the above values in app.config configuration elements rather than code, but I won't cover that here.

You can use (with descending levels of security):
System.Security.Principal.TokenImpersonationLevel.Identification
System.Security.Principal.TokenImpersonationLevel.Impersonation
System.Security.Principal.TokenImpersonationLevel.Delegation

Details on these impersonation levels can be found at: http://msdn.microsoft.com/en-us/library/system.security.principal.tokenimpersonationlevel.aspx

Config Changes


<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ListsSoap">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<client>
<endpoint address="http://servername/_vti_bin/Lists.asmx"
binding="basicHttpBinding" bindingConfiguration="ListsSoap"
contract="ServiceReference1.ListsSoap" name="ListsSoap1" />
</client>
</system.serviceModel>
</configuration>

83 comments:

  1. I used similar code to call to CRM4.0 service in a different domain, but I still did not make it work. I got message "The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.".

    ReplyDelete
  2. Hi David,
    You really saved my day today

    I used the same security settings NTLM for my web.config file.
    it resolved the error which i used to get
    The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'

    ReplyDelete
  3. Thanks David,

    You really saved a lot of my time with this post!
    Your solution worked for me.

    Best regards,
    Dmitry

    ReplyDelete
  4. thanks a ton man, saved me from pulling my hair out on this one.

    ReplyDelete
  5. Thanks a million, this really helped me!

    ReplyDelete
  6. Great post! Saved me a lot of time.

    Thanks!!

    ReplyDelete
  7. Thanks David, you save my time.

    ReplyDelete
  8. After changing the all it shown following error.
    Could not load file or assembly 'Indx.Xhq.Client.Solution, Version=100.38.0.4, Culture=neutral, PublicKeyToken=145342ae5acb8abb' or one of its dependencies. Access is denied.

    could you please help out this?

    ReplyDelete
  9. After changing the all it shown following error.
    Could not load file or assembly 'Indx.Xhq.Client.Solution, Version=100.38.0.4, Culture=neutral, PublicKeyToken=145342ae5acb8abb' or one of its dependencies. Access is denied.

    could you please help out this?

    ReplyDelete
  10. Thank you

    You saved a lot of my time. Your blog is really helpful

    ReplyDelete
  11. You saved my behind, thanks :-)

    ReplyDelete
  12. Still didn't fix it for me :(

    ReplyDelete
  13. Tableau Data Visualization Software
    SQIAR (http://www.sqiar.com/solutions/technology/tableau) is a leading Business Intelligence company and provides Tableau Software consultancy across United Kingdom and USA.

    ReplyDelete
  14. Can I set default cridential programmatically, I use multiple wcf client with NTLM Authentication, so i can set once cridential for all wcf client

    ReplyDelete
  15. Can I set default cridential programmatically, I use multiple wcf client with NTLM Authentication, so i can set once cridential for all wcf client

    ReplyDelete
  16. Can I set default cridential programmatically, I use multiple wcf client with NTLM Authentication, so i can set once cridential for all wcf client

    ReplyDelete
  17. Thanks this helped a lot, I was using basic authentication, so only used the web.config part and provided user Id and Password like this:

    MyService client = new Myservice();

    client.ClientCredentials.UserName.UserName = @"domain\UserName";
    client.ClientCredentials.UserName.Password = "Password";
    var response = client.GetCurrentTransmissions("F2FD76FD-5DF7-4915-972D-703C403F932E");

    And My web.config looks like this :

    "







    "

    ReplyDelete
  18. How to call without username and password? But i will use window authentication. Please.

    ReplyDelete
  19. Get Mutual Fund Investment Schemes by Mutual Fund Wala and know about the best investment platform for you, to get profit.
    Mutual Fund Agent

    ReplyDelete
  20. Awesome information, visit our page lifestyle magazine to get the best fashion and lifestyle magazines.
    Lifestyle Magazine India

    ReplyDelete
  21. Thanks for your efforts for this blog. Visit Kalakutir Pvt Ltd for Caution & Indication Signages and Warehouse Zebra Painting.
    Warehouse Zebra Painting

    ReplyDelete
  22. In azure, the career has good growth in a cloud environment azure training

    ReplyDelete
  23. There professional for SQL has a good hope pl sql training

    ReplyDelete

  24. Wow!!! It was really an Informational Article which provide me with much Insightful Information. I would like to first thank the author for such an Insightful Content. If someone here is looking for a Website Designing Company in India, then look no further than Jeewangarg.com as we are the best website designing company in Delhi working in the arena for the last 8 years.
    Best website designing company in India
    website designing company in Delhi NCR
    Google Partner in India

    ReplyDelete
  25. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing Learn Tableau Online clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..

    ReplyDelete
  26. Iogoos Solution offers the best SEO Services in India with full satisfaction Services. Increase organic traffic to rank your website top on Google search Engine Result Page. We are the top rated SEO Company in India.

    Website Designing Services
    Shopify Development Services
    Digital Marketing Services in India

    ReplyDelete
  27. Book My House Maid provide best & Reliable Maid Services in Delhi. We provide both flexible and permanent staffing services.

    Babysitting Services in India
    Housekeeping Services in India

    ReplyDelete
  28. Search our best SEO Services in India. Provide professional SEO Services increase Visibility of your Website on the Search Engine. Hire best SEO Services in India here. affordable SEO Company in India

    ReplyDelete
  29. This is exactly where Digital Marketing Services in India comes into perform, using efficient internet marketing services such as Search engine optimization, Link building, Email marketing etc. not just ensures that your market potential boosts multifold, it also signifies that your client base increases significantly too.

    ReplyDelete
  30. 123movies Many Thanks for the shared this informative and interesting post with me.

    ReplyDelete
  31. Mobile App Coder Offers the best React Native App Development Services in India at an affordable Price with full satisfaction. We are the one of the top leading React Native App Development Company in India.

    ReplyDelete
  32. Awesome information about topics.Graymen Technologie offers PHP Development Services are best way to increase your online business through attractive website.

    ReplyDelete
  33. Looking for Website development Services in India? Visit Drudge media, #1 website application development Company across India & USA. We deliver best Quality Services at lowest price.

    ReplyDelete
  34. We are one of the Top Rated Data Entry Services in India & Virtual Assistance Service Company in India. We provide ebook data entry, data cleaning, data conversion, data mining services.

    Virtual Assistant Services in India

    ReplyDelete
  35. Super Pharmacy USA is the best Online Pharmacy offering various online medicines such as Propecia, Tamiflu, Tapentadol, Modalert, Modafinil, Eszopiclone and much more at your doorstep. We are providing best online Medicines at an affordable price.

    ReplyDelete
  36. Very Good Information...
    Looking to buy Modalert 200mg Online? Myanxietypills offers the best online medicines at your budget with full satisfaction services. So hurry, buy Modalert online now!

    buy tapentadol 100mg online

    ReplyDelete
  37. When you are brash and indiscreet and decide to buy Tramadol 100mg online you could end up being addicted to it. You will start having a compulsive desire to use the drug and your daily functions will become difficult if you stop using the drug. Therefore, you must be careful about these points when you use this drug.

    Buy Tapentadol Online

    ReplyDelete
  38. From our selection of Town Call Girl, we’ve never seen such a toned body as Vip Escort in Ludhiyana Simranpreet Kaur before, look at that waist and hips! they really love taking care of her stunning body so that she can keep up with you all night long. Town are young, playful, and extremely sexy. You can have all the filthy things Ludhiyana Escort Service offers, there really is nothing not to love. So, what are you waiting for? This little minx is ready to give you the night of your life! Find out more here on our blog. Do you want to experience an unforgettable evening? Then book a meeting with our Call Girl in Town today.
    Female Call Girls in Nurpur !!
    Female Call Girls in Palampur !!
    Female Call Girls in Paonta Sahib !!
    Female Call Girls in Parwanoo !!
    Female Call Girls in Rawalsar !!
    Female Call Girls in Rohru !!
    Female Call Girls in Shimla !!
    Female Call Girls in Solan !!
    Female Call Girls in Theog !!
    Female Call Girls in Una !!

    ReplyDelete
  39. Great information, thanks for sharing this excellent blog with us. Ogen Infosystem is one of the leading Website Designing Company and SEO Services providers in Delhi. Visit our website for more information.
    Best Website Designing Company in India

    ReplyDelete
  40. I have been searching for such an informative publication for many days, and it seems that my search here has just ended. Good job. Continue publishing.
    aluminum composite panelling ,aluminium composite panel cladding ,aluminum cladding sheet

    ReplyDelete
  41. Wonderful post, I really like your point of view about this particular topic. Here are 6 Things to Consider Before Hiring Expert Java Programmers that might help you.

    ReplyDelete
  42. As travel is starting we need to follow some precautionary measures that we need to wear masks, use proper sanitizers. Wash our hand again and again after some time also if we filling sick then we must avoid traveling. These are some main measures which we need to follow.
    Rajasthan tour packages

    ReplyDelete
  43. You can watch all the live streaming TV shows on the internet using a FuboTv with more than 180 channels. Its packages is made such that you can get all the channels right from your device less than 5 minute after connect it. This is the best package that gives you hundreds of TV channels online. fubo.tv/Connect

    ReplyDelete
  44. This comment has been removed by the author.

    ReplyDelete
  45. Try offensive language detection at Textrics that become the best software for analyzing abusive language behavior. It is helpful for market research, e-commerce, FMCG, the healthcare sector, and more.
    Sentiment AnalysisNamed Entity Recognition

    ReplyDelete
  46. This comment has been removed by the author.

    ReplyDelete
  47. Very interesting blog. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome.You can also check my articles as well.
    security services
    security guard license online
    shopping mall security
    event security

    ReplyDelete
  48. Thank you for making this blog and for sharing useful information. Continue doing your passion and keep on blogging.
    Online School Management Software In India

    ReplyDelete
  49. This comment has been removed by the author.

    ReplyDelete
  50. This comment has been removed by the author.

    ReplyDelete

  51. Thanks for sharing helpful blog, Global Platter is one of the Food Stylist and Best food photographer in Delhi and NCR area. She specializes in Food, Product and Commercial Photography.

    Professional Food Photographer in Delhi
    Best Product Photographer in Delhi

    ReplyDelete
  52. Get an Executive health checkup at home that covers 63+ tests Lipid, Liver, Renal, Thyroid, Cardiac Risk Manager, Complete Hemogram, Diabetes, Iron Deficiency, and more, along with other tests. So, Book complete health checkup care plus at your nearest lab with Mediyaar Healthcare at the lowest price.

    ReplyDelete
  53. Boost your website rank with Affordable SEO Services in USA, offered by Unisoft Informatics. We provide the best digital solution to generate high revenue. Visit our website to know more about our digital marketing services.
    Affordable SEO Services in USA
    Professional SEO services USA

    ReplyDelete
  54. Information is pretty good and impressed me a lot. This article is quite in-depth and gives a good overview of the topic. If you are looking for SIL & Functional Safety studies or DERA DUST EXPLOSION RISK ASSESSMENT than contact us.

    ReplyDelete
  55. Thanks for sharing this Interesting post with the community! cataract surgery cost in chennai is now feasible on RK eye centre.

    ReplyDelete
  56. Hi, I am John Smith I am Web Developer, It is an amazing blog thanks for the sharing the blog. Frantic infotech provide the android Social App Development such as an information about software development for costumer service. Frantic infotech also provide the Android Ecommerce App Development. Theve delopment of advanced web applications is Orient Software’s specialty and we will successfully fulfill all your web application development requirements, from small-sized to wider-ranged projects.

    ReplyDelete
  57. Thanks for Sharing Helpful Blog, Native Organica - Best Organic products, vegetables & fruits online in Delhi, Gurgaon, Faridabad & Noida. Best products & price guaranteed. Cash on delivery available. Native Organica offers staple food products which can guarantee a healthier lifestyle for you and your family and avoid the unseen damage of using popular but unhealthy products in the current market. Also Read - Buy Organic Food Online in Gurgaon

    ReplyDelete
  58. This is an excellent article. This webpage has a lot of value for me. Keep it up!.Oracle Fusion SCM Online Training

    ReplyDelete
  59. Connect with the most famous offline and Online Medical Books store that is AIBH. They are providing services since 1950.

    ReplyDelete
  60. stim ortho brush is designed completely in India. It is super -fine product.

    ReplyDelete
  61. Buy 25 watt soldering iron with an advanced heating element, low current leakage, rubber grip, nylon handle.

    ReplyDelete
  62. wordpress website design studio Need professional WordPress Web Design Services? We're experts in developing attractive mobile-friendly WordPress websites for businesses. Contact us today!

    ReplyDelete
  63. I got a lot of information to it, thanks.

    Hello guys now you can choose a professional and experienced food and product photographer in Delhi, India

    https://manishrajput.com/

    ReplyDelete
  64. Very Nice Information...
    Thanks For Sharing.

    TStore offers a wide range of Women's t-shirts online in India. Get Attractive and Quality T-Shirts at the lowest price. Buy T-Shirts for Women Online in India now.

    Also See:

    buy plain t-shirts online for women
    buy printed t shirts for women
    buy Half Sleeve T-Shirts for Women
    buy polo t-shirts for women
    buy hoodies for women online
    buy full sleeve t-shirts for women online
    buy oversized t-shirts for women online

    ReplyDelete
  65. Oral and maxillofacial surgery is one of the most varied and exacting surgical specialities combining the full range of hard and soft tissue surgical skills in a complex anatomical region. This book aims to serve the readers as a guide and ready-reckoner of clinical aspects of oral surgery.

    ReplyDelete
  66. Root canal treatment is an important procedure used to treat dental problems. It is necessary when the soft tissue inside a tooth becomes infected or damaged. Tabrizi Dental Associates is one of the leading providers of root canal treatments in the United States, offering their clients state-of-the-art technology and exceptional care.

    ReplyDelete
  67. Dr. Manjit Singh Babbar is widely regarded as the leading best laparoscopic surgeon in Gurdaspur due to his vast experience, advanced skills, and patient-centric approach.

    ReplyDelete
  68. https://scansworldonchamiersroad.com/nandanam Diagnostic centre in Nandanam offers comprehensive imaging and pathology services with state-of-the-art equipment and expert staff. Located conveniently, it provides accurate and prompt scanning, lab tests, and health assessments in a comfortable setting. Patients benefit from reliable diagnostics, friendly care, and efficient reporting, making it a trusted choice for preventive and medical evaluation needs in Nandanam.

    ReplyDelete
  69. Excellent write-up! I genuinely enjoyed how you connected cybersecurity concepts with real-world applications, making the content both informative and practical. It clearly highlights how important it is for learners to go beyond textbooks and gain hands-on experience. From what I’ve seen, platforms like Digital Marketing Training in Hyderabad emphasize practical learning, expert mentorship, and live project exposure. This combination not only strengthens understanding but also prepares individuals for real industry challenges. Your article strongly reinforces the idea that skill-based education is the future.

    ReplyDelete