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?

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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