gpt4 book ai didi

c# - 客户端对象模型,找不到站点用户?

转载 作者:太空宇宙 更新时间:2023-11-03 21:22:37 25 4
gpt4 key购买 nike

我在运行程序时收到 ServerException。这是我的代码:

 ClientContext context = new ClientContext("http://myRUL");
Principal user = context.Web.SiteUsers.GetByLoginName(@"myRealAccoutLoginIn");
RoleDefinition readDef = context.Web.RoleDefinitions.GetByName("Approve");//"Approve" is the permission I want to give to the user

RoleDefinitionBindingCollection roleDefCollection = new RoleDefinitionBindingCollection(context);
roleDefCollection.Add(readDef);
RoleAssignment newRoleAssignment = context.Web.RoleAssignments.Add(user, roleDefCollection);

context.ExecuteQuery();

这里是 enter image description here细节异常:

我可以向您保证网站上存在 SiteUsers,下图中的红色圆圈是我的共享点帐户: enter image description here

最佳答案

Web.SiteUsers 在 SharePoint 2010 中不存在,不推荐在 SharePoint 2013 中使用。

尝试使用 Web.EnsureUser("<username>") ( documentation ) 获取委托(delegate)人。

关于c# - 客户端对象模型,找不到站点用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29752490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com