0

I get an error in thecontext.ExecuteQuery();line while trying to connect to the server.

        Console.WriteLine("Please enter your username for PWA");
        userName = Console.ReadLine();
        Console.WriteLine("Please enter your password for PWA");
        passWord = Console.ReadLine();


        NetworkCredential netcred = new NetworkCredential("user", "password");
        SharePointOnlineCredentials orgIDCredential = new SharePointOnlineCredentials(netcred.UserName, netcred.SecurePassword);
        context.Credentials = orgIDCredential;

The error ist

Microsoft.SharePoint.Client.ClientRequestException: 'The IDCRL response header from server 'http://xxx.xxx.de/' is not valid. The response header value is 'NTLM'.

If i use context.Credentials = netcred; I get a different error

System.Net.WebException: 'The remote server returned an error: (401) Unauthorized'.

But I am authorized.

Any ideas how to fix it?

1 Answer 1

0

look at this post, here had the same problem, don't forget to use domain before loginname and don't use SharePointOnlineCredentials when you are connecting to SP2016.

You should use something like this (from the post):

string _siteURL = "https://intranet.co.uk";
NetworkCredential _myCredentials = new NetworkCredential("user", "password", "https://intranet");
ClientContext _clientContext = new ClientContext(_siteURL);
_clientContext.Credentials = _myCredentials;
Web _MyWebSite = _clientContext.Web;

Hope it helps!

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.