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>

70 comments:

Hardy said...

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'.".

pranam said...

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'

DRU said...

Thanks David,

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

Best regards,
Dmitry

mknopf said...

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

John said...

Thanks a million, this really helped me!

Kjell W. said...

Great post! Saved me a lot of time.

Thanks!!

Ravi said...

Thanks David, you save my time.

kaviya Balasubramanian said...

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?

kaviya Balasubramanian said...

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?

Unknown said...

Thank you

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

Anything Interesting said...

Saved my time too..

Anything Interesting said...

Saved my time too...

Unknown said...

You saved my behind, thanks :-)

BlogBrett said...

Still didn't fix it for me :(

Unknown said...

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.

Shconer Design said...

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

Julka Hendri said...

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

Julka Hendri said...

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

Unknown said...

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 :

"







"

Lar Shar Kyi said...

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

Unknown said...

This is very nice blog,and it is helps for student's Tableau Online Training

Pankaj Singh said...

Nice blog, keep more updates about this type of information. Visit for the best Website Designing and Development Company in Delhi.
Website Designing Company in Delhi

Mutual Fundwala said...

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

Kala Kutir said...

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

Just Info said...

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

gautham said...

thanks for your post blockchain online training hyderabad

gautham said...

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

gautham said...

There professional for SQL has a good hope pl sql training

Jack sparrow said...

I am a regular reader of your blog and I find it really informative. Hope more Articles From You.Best Tableau tutorial videos available Here. hope more articles from you.

jeewangarg said...


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

nexusups said...

Thanks for the great article and post. Need a Industrial UPS? Don’t go beyond nexusups. “A popular Industrial UPS which offers an extensive range of exceptional Industrial UPS, and Online Online UPS Free to contact.

Servo said...

Thanks for the great article and post. Need a servo voltage stabilizer manufacturers in india? Don’t go beyond servo star “A popular stabilizer price which offers an extensive range of exceptional servo stabilizer. Feel Free to contact.

svrtechnologies said...

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..

Pradeep Appslure said...

Mobile app development company in gurgaon

rightselects said...


Thank You author for providing such insightful information on elevators, if anyone out there is looking for Passenger lifts then, visit right selects where you’ll get the most accurate information on the top 10 elevator companies in india that you can use to choose the best elevator company in India.

Iogoos Solution said...

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

Book My House Maid said...

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

Kartik Web Technology said...

Kartik Web Technology is one the best web Designing company in Gurgaon in India. We are also specialized in graphic designing, multimedia works and custom web development. Our services include web designing web development & friendly web designs @ affordable prices. End to End Service. Get Free Proposal now. Get you Business Online

website designing company in Gurgaon

Core SEO Services said...

Search our best SEO Services in India. Provide professional SEO Services increase Visibility of your Website on the Search Engine. CSS is a top Rated SEO Company in India.


Digital Marketing Company in India
Website Designing Company in India
Lead Generation Services in India
Website Development Services in India

Unknown said...

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

Nisha Sharma said...

Mobile app development company in mumbai

Oflox said...

Really Nice Post & Thanks for sharing.
Oflox Is The Best Website Development Company In Dehradun

My Reputation Vault said...

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.

rightselects said...

If you are also thinking of buying the best and excellent quality of ACP sheets then Right Selects has created an excellent solution for you. We have made the list of top 10 Aluminum composite panel manufacturers in India. Moreover, we have been emerged as your mini Google who are providing you with the information of the top 10 leaders/ manufacturers of the particular industry. Go through this blog to get a clear idea of best Aluminum Composite Panel manufacturers.

whatsapp plus themes said...

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

Mobile App Coder said...

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.

Graymen Technologies said...

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

nandhini said...


Well researched article and I appreciate this. The blog is subscribed and will see new topics soon.
Microsoft Windows Azure Training | Online Course | Certification in chennai | Microsoft Windows Azure Training | Online Course | Certification in bangalore | Microsoft Windows Azure Training | Online Course | Certification in hyderabad | Microsoft Windows Azure Training | Online Course | Certification in pune

Drudge Media said...

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.

Get Virtual Support said...

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

meritstep Technology said...

Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
blockchain online training
best blockchain online training
top blockchain online training

domnic wade said...

Thanks for sharing the infromative article. It is really very valuable Information and helped me to get some nice ideas. Keep doing such great work.

office.com/setup
mcafee.com/activate

Super Pharmacy USA said...

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.

Vegas Marketing said...

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 Guard License
Ontario Security License
Security License Ontario
Security License

Thank you..

Get Virtual Support said...

We are one of the leading bookkeeping and data management service providers in India. We always strive to provide top-grade solutions using advanced tools at affordable prices. Many Services provided by getvirtualsupport are below:

Online Bookkeeping Services in India
Data conversion services in India
Online Bookkeeping Services India
Data Entry Services in India
Virtual Assistant Services in India
Data Entry Services in India
Virtual Assistant Services India
Online Bookkepping Services
Virtual Assistant Services

Mobile App Coder said...

Mobile App Coder is a leading mobile App Development Company offering best mobile App Development Services in India at reasonable price with full satisfaction services. We provides various services given below:

Mobile App Development Services in India
React Native App Development Services in India
Android App Development Company in India
Android App Development Company
Android app development company India
React Native App Development Services in India
Android App Development Services in India
Android App Development Company in India
mobile app development Services in India
Android App Development services in India
iPhone App development Company in India
iPhone App development Company in India
Android App Development services in India

meritstep Technology said...

Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
blockchain online training
best blockchain online training
top blockchain online training

Pankaj Singh said...

This post was really thinkable for me, please updates more information about this related blog. Visit Ogen Infosystem for quality web design and SEO Services in your budget.
SEO Service in Delhi

myanxietypills said...

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

Graymen Technologies said...

Awesome information about topics. Graymen Technologie offers Wordpress Development Company in India are best way to increase your online business through attractive website.

My Reputation Vault said...

Great Information Thanks for sharing with us.

If you are looking for best ORM Services in India? Visit myreputationvault. We are th best ORM Company in India...

Image Removal Services on Google
Measured Up Removal Services
Cheaterland Removal Services
Real Estate Online Reputation Management Services
Ripoff Report Removal Services On Google

Unknown said...

Water bodies are the main source of transportation for international freight forwarding. Due to this, sea freight company in Delhi,
visit
Freight Forwarder in Vietnam
Shipping Company In India

Unknown said...

visit here
iso certification in delhi
iso certification in noida
iso certification in gurgaon
iso certification in faridabad

Jack Stratford said...

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

Ayonzaustralia said...

Ayonz is a Market Development Company in Sydney provides a service solution that is end-to-end like technology design, manufacturing, supply & brand development for consumer lifestyle products sold in retail, through resellers or online shopping channels.

Emily Kenley said...

Very Unique Article!
Thank You for Sharing This...

Looking to buy Zopiclone 7.5mg Online or cash on delivery then visit us. We deliver best quality of online Medicines across the USA at your doorstep with full satisfaction.

Order Zopiclone Online
Buy Zopiclone Online
Buy Zopiclone 7.5mg Online
Zopiclone Online
Zopiclone
Buy Zopiclone
Zopiclone 7.5mg
Order Zopiclone Online

Super Pharmacy USA said...

Very Nice Blog! Thanks For Sharing!

If you want to buy online Medicines then visit superpharmacyusa, here we deliver best quality of online Medicines at your doorstep. You can buy Tapentadol Online or Tapetadol Cash on Delivery.

Order Tapentadol Online
Buy Tapentadol 100mg online
Buy Tapentadol Online
Tapentadol
Buy Tapentadol
Tapentadol 100mg
Buy Tapentadol Online
Tapentadol Cash on Delivery
Tapentadol

Emily Kenley said...

Very Unique Article!
Thank You for Sharing This...

Looking to buy Zopiclone 7.5mg Online or cash on delivery then visit us. We deliver best quality of online Medicines across the USA at your doorstep with full satisfaction.

Order Zopiclone Online
Buy Zopiclone Online
Buy Zopiclone 7.5mg Online
Zopiclone Online
Zopiclone
Buy Zopiclone
Zopiclone 7.5mg
Order Zopiclone Online

Sapna Rajput said...

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 !!

Pankaj Singh said...

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