I have a console application that connects to the SharePoint and works with lists (I'm using SharePoint Client model). Code that connects with SharePoint is:

SPCli.ClientContext _clientContext = new SPCli.ClientContext("server-url");
_clientContext.Credentials = new System.Net.NetworkCredential("username", "password");
SPCli.Web web = _clientContext.Web;

As you can see, the program has access to SharePoint, the user must manually enter his login data. For example, user's login data in Windows and SharePoint are the same. It is possible to transfer authorized Windows's user credentials to SharePoint? I tried to look for ways to do it at https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.aspx, but I didn't find the solution.

  • Are you need to avoid manually login ? Aug 2 '16 at 11:48
  • Yes, I want to try the automatic authorization without manually input Aug 2 '16 at 12:09
  • Are you tried to use clientContext.Credentials = CredentialCache.DefaultNetworkCredentials; Aug 2 '16 at 12:18
  • Yes, but i got an error "401 unauthenticated error" Aug 2 '16 at 12:21
  • The windows user should have the sufficient permission on the site , make sure the windows login user have access to SharePoint site Aug 2 '16 at 12:23

Try to use this

_clientContext.Credentials = CredentialCache.DefaultNetworkCredentials

And make sure that the current windows login user that run your application have the sufficient permission to access the SharePoint site and the resource (like List or Library ...etc) that you need to do action on it within site.

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.