I know that many questions about SO are similar to this, but I could not find it for this particular problem.
A few points, firstly:
- We have no control on our Sharepoint server. I cannot configure any IIS settings.
- I believe our version of the IIS server is IIS 7.0.
- Our Sharepoint server listens for requests through NTLM.
- Our Sharepoint server is in the same domain as my client computer.
- I am using .NET Framework 3.5, Visual Studio 2008
I am trying to write a simple console application for managing Sharepoint data using SharePoint web services. I added a link to the service, and the following is my app.config:
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="ListsSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="Transport"> <transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="https://subdomain.companysite.com/subsite/_vti_bin/Lists.asmx" binding="basicHttpBinding" bindingConfiguration="ListsSoap" contract="ServiceReference1.ListsSoap" name="ListsSoap" /> </client> </system.serviceModel>
This is my code:
static void Main(string[] args) { using (var client = new ListsSoapClient()) { client.ClientCredentials.Windows.ClientCredential = new NetworkCredential("username", "password", "domain"); client.GetListCollection(); } }
When I call GetListCollection (), the following MessageSecurityException is thrown :
The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'.
With an internal WebException:
"The remote server returned an error: (401) Unauthorized."
I tried various bindings and various code settings to try to authenticate properly, but to no avail. I will list below.
I tried the following steps:
Using your own Win32 Impersonator before creating a client
using (new Impersonator.Impersonator("username", "password", "domain")) using (var client = new ListsSoapClient()) { client.ClientCredentials.Windows.ClientCredential = new NetworkCredential("dpincas", "password", "domain"); client.GetListCollection(); }
This caused the same error message.
Configure TokenImpersonationLevel for my client credentials
using (var client = new ListsSoapClient()) { client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation; client.GetListCollection(); }
This caused the same error message.
Using Security Mode = TransportCredentialOnly
<security mode="TransportCredentialOnly"> <transport clientCredentialType="Ntlm" /> </security>
As a result, another error message appeared:
The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via
However, I need to use https, so I cannot change the URI scheme.
I tried some other combinations that I donβt remember, but I will publish them when I will. I really am here. I see a lot of google links saying "switch to Kerberos", but my server seems to accept NTLM, not "Negotiate" (as it would be said if it searches for Kerberos), so unfortunately this is not an option .
Any help there people?