【发布时间】: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
【问题讨论】:
-
您只能删除不能继承的权限。只能删除未继承的共享权限。这是相关文档 - docs.microsoft.com/en-us/graph/api/…