Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Fetching Anonymous/Organization Review Link (or confirming existence thereof) #2949

Closed
chuushi opened this issue Mar 28, 2023 · 1 comment · Fixed by #3181
Closed
Assignees
Labels
enhancement New feature or request

Comments

@chuushi
Copy link

chuushi commented Mar 28, 2023

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!

@chuushi chuushi added the enhancement New feature or request label Mar 28, 2023
@gautamdsheth gautamdsheth self-assigned this Jun 12, 2023
gautamdsheth pushed a commit to gautamdsheth/powershell that referenced this issue Jun 12, 2023
gautamdsheth added a commit that referenced this issue Jun 12, 2023
Feature #2949 : added cmdlets to retrieve shared links for files and folders
@gautamdsheth
Copy link
Collaborator

Added Get-PnPFileSharingLink and Get-PnPFolderSharingLink cmdlets to retrieve these values.

Will be available in tomorrow's nightly builds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants