I'm working on an SSIS script task that uploads a file to a SharePoint site and applies item level permission to the file. I use a windows account to establish a connection with SharePoint library like below.
using (ClientContext ctx = new ClientContext("http://server"))
{
ctx.Credentials = new NetworkCredential("username", "password", "domain");
//ctx.Credentials = CredentialCache.DefaultCredentials;
Web currentWeb = ctx.Web;
ctx.Load(currentWeb);
ctx.ExecuteQuery();
using (FileStream fs = new FileStream(@"filepath", FileMode.Open))
{
Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctx, "site path to save", fs, true);
}
}
The account has administrator permission to the SharePoint site, so it makes a connection to it perfectly and the file gets uploaded without any issues. Now there is another account, let's call it Account B, which has full administrator access at both site and site collection levels. But still I get an error 'The remote server returned an error : 401 Unauthorized' when I try executing the above code with this account B. Is there any other permission that is required to establish a connection to the SharePoint library/site using client object model?