【问题标题】:Remove user from folder permission using MS Graph使用 MS Graph 从文件夹权限中删除用户
【发布时间】:2020-11-19 10:40:23
【问题描述】:

我们有一个 C# 应用程序,它使用 Microsoft Graph API 在 Syncfusion FileManager 控件中向用户显示 SharePoint 文件夹的内容。我们需要为某些用户授予对这些文件夹的权限,以便他们可以协作处理文件。 我们可以使用共享邀请添加特定用户以添加权限(请参阅https://docs.microsoft.com/en-us/graph/api/driveitem-invite?view=graph-rest-1.0&tabs=http)。我们还需要能够在不删除整个链接(以及因此使用它的任何其他用户)的情况下从该权限中删除用户。我看不到这样做的方法!

我也尝试过使用 CreateLink(请参阅 https://docs.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http),但在尝试向用户“授予”权限时出现“无效请求”错误,因此从未尝试删除单个用户!我用来尝试和“授予”权限的代码如下(最后一行产生错误):

public object CreateSharingLink(string itemId, List<string> recipientList, List<string> roles)
{
    if (itemId == null) return null;

    var type = "edit";
    var scope = "organization";

    Permission p = GraphClient.Drives[documentLibrary.Id].Items[itemId].CreateLink(type, scope).Request().PostAsync().Result;

    return GrantAccessToSharingLink(p.Link.WebUrl, recipientList, roles);
}

public object GrantAccessToSharingLink(string sharingUrl, List<string> recipientList, List<string> roles)
{
    List<DriveRecipient> recipients = (recipientList.Select(r => new DriveRecipient { Email = r })).ToList();
       
    string base64Value = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(sharingUrl));
    string encodedUrl = "u!" + base64Value.TrimEnd('=').Replace('/', '_').Replace('+', '-');

    return GraphClient.Shares[encodedUrl].Permission.Grant(roles, recipients).Request().PostAsync().Result;
}

任何帮助将不胜感激。

不久前有人问过类似的问题,但没有答案。 Remove GrantedTo user from Permission using Graph API

【问题讨论】:

标签: c# microsoft-graph-api


【解决方案1】:

您只能删除未继承的权限。只能删除未继承的共享权限。这是相关的doc

【讨论】:

  • 这并不能解决问题。这将删除共享链接所附加的整个权限,从而删除所有用户对共享链接的所有访问权限。
猜你喜欢
  • 2022-08-12
  • 2015-05-15
  • 2012-08-29
  • 2020-06-16
  • 2011-08-06
  • 2022-12-06
  • 2017-02-04
  • 2012-11-10
  • 1970-01-01
相关资源
最近更新 更多