我尝试将外部用户添加到直接访问权限,并且获得了具有编辑权限的特定人员链接。然后我尝试使用特定文件的角色分配来获取链接详细信息,并且外部用户不可见。用户验证并使用打开文件后,外部用户在以“SharedLinks...”开头的组名下可见。
我的问题是“是否可以使用 CSOM 获取外部用户的邀请?”如果是,那么我该怎么做。
我还找到了一些参考来获取 Rest API 调用中的详细信息,
https://42jghx.sharepoint.com/sites/1gate/_api/web/Lists(list_id)/GetItemById(item_id)/GetSharingInformation?$Expand=permissionsInformation&$Select=permissionsInformation
使用此 Api 调用,我可以获得该项目的许可以及其中包含外部用户邀请的共享链接的详细信息。
上述API调用有相关的CSOM C#代码吗?
以下示例说明了如何在 C# 中使用 CSOM 来获取有关外部用户邀请的详细信息:
using System;
using Microsoft.SharePoint.Client;
class Program
{
static void Main()
{
// Replace these values with your SharePoint site URL and credentials
string siteUrl = "https://your-sharepoint-site-url";
string username = "[email protected]";
string password = "your-password";
using (ClientContext context = new ClientContext(siteUrl))
{
// Provide credentials
context.Credentials = new SharePointOnlineCredentials(username, password);
// Get the site collection
Site site = context.Site;
context.Load(site);
context.ExecuteQuery();
// Get the external user invitations
var externalUserInvitations = site.GetInvitations();
context.Load(externalUserInvitations);
context.ExecuteQuery();
// Display invitation details
foreach (var invitation in externalUserInvitations)
{
Console.WriteLine($"Invitation ID: {invitation.InvitationId}");
Console.WriteLine($"Email: {invitation.InvitedUserEmail}");
Console.WriteLine($"Invited by: {invitation.InvitedBy}");
Console.WriteLine($"Invited on: {invitation.InvitedOn}");
Console.WriteLine($"Invitation status: {invitation.Status}");
Console.WriteLine();
}
}
}
}