model-view-controller - SharePoint 客户端对象模型在 clientContext.ExecuteQuery() 方法上返回 "User Cannot Be Found"

标签 model-view-controller office365 csom

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/

相关文章:

c# - 如何将导航栏操作链接固定在右侧

azure - 无法访问 Azure 上的 OpenId UserInfo 端点(AADSTS90010 : JWT tokens cannot be used with the UserInfo endpoint)

sharepoint - 检查当前用户是否可以查看 SharePoint CSOM 中的列表

java - CustomTableModel + JTable = 表未填充

php - CakePHP:将 'Services' 逻辑放在哪里

office365 - 自动化 OneDrive for Business 本地设置以与文件夹重定向一起使用

javascript - 使用 JavaScript 更改 SharePoint 列表的权限

sharepoint - 以编程方式从内容类型中删除字段引用 (CSOM)

asp.net-mvc - 这种逻辑的正确位置在哪里?

c# - 如何使用 Azure AD 对 Windows 服务进行身份验证以将事件上传到 Office 365 日历?