【发布时间】:2015-04-28 10:56:06
【问题描述】:
我有基于声明的身份验证的 SharePoint 2013 WebApp。此 WebApp 还启用了提供的受信任身份。现在我正在尝试使用以下代码从控制台应用程序连接到网站集之一。
using (var clientContext = new ClientContext(url))
{
var rootweb = clientContext.Web;
clientContext.Load(rootweb );
clientContext.ExecuteQuery();
}
每次执行时我都会收到错误: 远程服务器返回-an-error-403-forbidden-error 即使有下面的代码和平
using (ClientContext context = new ClientContext("SiteURL"))
{
CredentialCache cc = new CredentialCache();
NetWorkCredential nc = new NetworkCredential("username", "password", "domain");
cc.Add(new Uri("http://localhost"), "Negotiate", nc));
context.Credentials = cc;
Web web = context.Web;
context.Load(web);
Log.Debug("Loading web.");
context.ExecuteQuery();
Console.WriteLine(web.Title);
}
错误仍然相同。 the-remote-server-returned-an-error-403-forbidden-error.
请建议我应该怎么做才能避免上述错误
【问题讨论】:
标签: console-application sharepoint-2013 sharepoint-clientobject