-
Notifications
You must be signed in to change notification settings - Fork 399
Description
Is your feature request related to a problem? Please describe.
I've been looking into a way to find out if someone shared a document with an anonymous/organization link.
There are several methods to fetch shared links, one of which is using [Microsoft.SharePoint.Client.ObjectSharingInformation]::GetObjectSharingInformation(context, object, bool, bool, bool, bool, bool, bool, bool), and accessing $_.SharingLinks always yields 5 items. This is always consistent in getting sharing links for views and edits, but it contains no information for organization/anonymous review links.
The review link can be created for Word documents, so that may have something to do with it. In the end, fetching review links seems impossible.
This is an example code that I use to rely on fetching any active Org/Anon share links.
$ctx = Get-PnPContext
$ListItems = Get-PnPListItem -List "Shared Documents"
$Item = $ListItems[0] # Just as an example
# Assuming $Item.HasUniqueRoleAssignments is true,
$SharingInfo = [Microsoft.SharePoint.Client.ObjectSharingInformation]::GetObjectSharingInformation($ctx, $Item, $false, $false, $false, $true, $true, $true, $true, $true)
$SharingLinks = $SharingInfo.SharingLinks
$SharingLinks[0] # always outputs a share link object with .LinkKind of "Direct", not really useful
$SharingLinks[1] # always outputs a share link object with .LinkKind of "OrganicationView"
$SharingLinks[2] # always outputs a share link object with .LinkKind of "OrganizationEdit"
$SharingLinks[3] # always outputs a share link object with .LinkKind of "AnonymousView"
$SharingLinks[4] # always outputs a share link object with .LinkKind of "AnonymousEdit"Describe the solution you'd like
I would like an implementation of a function to fetch a sharing link kind of "OrganizationReview" and "AnonymousReview" in code if that's possible.
Describe alternatives you've considered
I've been looking about the web and documentation to find any clues that can confirm if a role assignment allows external access, but I've been hitting a brick wall every time.
# Same first few lines as above code block
# Assuming $Item.HasUniqueRoleAssignments is true,
$roleAssignments = Get-PnPProperty -ClientObject $Item -Property 'RoleAssignments'
$RA = $roleAssignments[0] # As an example
$RA.RoleDefinitionBindings # At least one of the definitions would output "Review"
$member = Get-PnPProperty -ClientObject $RA -Property 'Member'
$member.PrincipalType # would output "SharePointGroup"
$member.Title # The title would start with "SharingLink.<GUID>.Flexible.<GUID>"
$users = Get-PnPProperty -ClientObject $member -Property 'Users'
$users.Count # if it's an org/anon link, this would output 0.This is the furthest I was able to go. I couldn't find the SharingLink from a GUID, and there was no further indication of whether this SharePointGroup was shared for anonymous access or organization access. I would appreciate any help in figuring out this issue.
Thank you!