I'm trying to connect to a SharePoint list via a C# console application either using a functional ID or with the default credentials.

Option 1:

SpService.Credentials = CredentialCache.DefaultCredentials;

Option 2:

SpService.Credentials = new NetworkCredential(user, pw, domain);

If I use Option 1, the program runs successfully on my local computer but throws a 401 – Unauthorized exception when ran on the server. If I use Option 2, it throws the same exception both locally and on the server on the GetListItems() method. If I don’t set the Credentials property at all, it also throws an exception in both places.

SpService.GetListItems(listName, null, query, viewFields, null, queryOptions, null);

I’ve tried to grant permissions to the functional ID in SharePoint, but the Add Permissions dialog cannot find the user.

1 Answer 1


Last time I connected from a console app, I connected like this:

   proxy.ClientCredentials.Windows.ClientCredential = creds;
   proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

Your Answer

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

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