【发布时间】:2016-06-03 10:22:03
【问题描述】:
我正在处理一个 SSIS 脚本任务,该任务将文件上传到 SharePoint 网站并将项目级权限应用于该文件。我使用 Windows 帐户与 SharePoint 库建立连接,如下所示。
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);
}
}
该帐户具有 SharePoint 网站的管理员权限,因此它可以完美地连接到该网站,并且文件可以毫无问题地上传。现在有另一个帐户,我们称之为帐户 B,它在网站和网站集级别都具有完全的管理员访问权限。但是当我尝试使用此帐户 B 执行上述代码时,我仍然收到错误“远程服务器返回错误:401 未授权”。是否需要任何其他权限才能使用客户端对象建立与 SharePoint 库/站点的连接型号?
【问题讨论】:
标签: c# sharepoint ssis sharepoint-clientobject