SharePoint 客户端对象模型在 clientContext.ExecureQuery() 方法上返回“无法找到用户”,下面是示例代码。
ListItemCollection listItemColl = null;
var securePassword = new System.Security.SecureString();
var pwd = WebConfigurationManager.AppSettings["password"];
foreach (char c in pwd)
{
securePassword.AppendChar(c);
}
var spUri = ConfigurationManager.AppSettings["Office365SharepointUri"];
var clientContext = new ClientContext(new Uri(spUri));
var onlineCredentials = new SharePointOnlineCredentials(WebConfigurationManager.AppSettings["userName"], securePassword);
clientContext.Credentials = onlineCredentials;
try
{
var strCamlQuery = new CamlQuery();
clientContext.Load(clientContext.Web);
var templist = clientContext.Web.Lists.GetByTitle("SomeValidListName");
clientContext.Load(templist);
strCamlQuery.ViewXml = "<View Scope=\"RecursiveAll\"></View>";
listItemColl = templist.GetItems(strCamlQuery);
clientContext.Load(listItemColl);
clientContext.ExecuteQuery();
}
catch (Exception)
{
throw;
}
我提供了有效的凭据,甚至能够通过浏览器使用提供的相同凭据访问 SharePoint 网站,没有任何问题。
以前有人遇到过这个问题吗?
环境: MVC 5 应用程序。 CSOM。 Visual Studio 。 C#
最佳答案
这是 SharePoint 中的错误,我与 SharePoint 高级支持人员进行了交谈。
如果创建这些列表的用户被完全删除,当您尝试访问这些列表时,CSOM 会抛出“找不到用户”异常,SP 会在内部检查创建该列表的用户。
解决方案是使用不同的用户重新创建这些列表。希望SP团队解决这个问题。
感谢您的回答。
关于model-view-controller - SharePoint 客户端对象模型在 clientContext.ExecuteQuery() 方法上返回 "User Cannot Be Found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37453481/