[英]Web service unable to connect Sharepoint site “unable to connect remote server”
我写了如下代码:
try
{
ClientContext context = new ClientContext("https://test.com/");
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
string strUserName = @"abc";
string strPassword = "pwd";
var credentials = new NetworkCredential(strUserName, strPassword);
Web web = context.Web;
context.Load(web, w => w.Title);
context.Credentials = credentials;
context.ExecuteQuery();
// Now, the web's properties are available and we could display
// web properties, such as title.
System.Console.WriteLine("Web Title");
System.Console.WriteLine(web.Title);
}
catch (Exception ex)
{
}
在控制台应用程序中它可以正常工作,但是当我从Web服务中调用时,相同的代码不起作用。
考虑到我们的讨论; 该问题很可能是您的IIS应用程序池所运行的帐户无权访问Sharepoint站点。 您需要应用程序池帐户在AD中具有访问权限才能使代码正常工作。 您需要执行以下操作之一;
获取授予Sharepoint AD权限的应用程序池帐户。 由于IIS 7及更高版本默认对应用程序池使用“奇数帐户”,因此这种可能性较小。
您更有可能需要将您的应用程序池所运行的帐户更改为具有适当AD权限的帐户。 在我工作过的大多数公司中,都有用于此目的的“服务帐户”或“自动帐户”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.