-
Notifications
You must be signed in to change notification settings - Fork 662
User with full control permission to a document library got permission denied with add-pnpfile #2476
Comments
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible. |
The way Add-PnPFile is implemented requires to iterate over the RootFolders of the Siteto find the one specified in the -Folder parameter. |
Also, even though the user can not use 'add-pnpfile' to copy a file but they can use web browser to upload a file to the document library. Shouldn't the two ways be consistent? If a user can upload a file through web browser, they should be add a file through add-pnpfile? |
One possible workaround until this issue is fixed is to get the folder with $folder = Get-PnPFolder $libraryName of type Microsoft.SharePoint.Client.Folder and then use CSOM to upload the file. |
I created a PR at #2478 . It's definitely not perfect as it still throws an "Access Denied" error if the specified Subfolder in the Library doesn't exist, but at least files get uploaded without any error using your How To Reproduce steps. |
Thanks, subfolder is not an issue, user can create subfolders without problem in existing document library as long as they have edit permission. They can't create document library, the top folder, without proper site wide permission, but that's expected. |
@jackpoz Don't know why your PR 2478 didn't get this "status:checked and ready for merge" sticker. A couple of newer PRs got that already. Looks like it won't be in the next release? |
It takes time to review and merge PRs, maybe it will be in next or the one after. Did you have time to test locally that PR ? Did it fix the issue/improve it ? |
This is a work related issue and I don't have Visual Studio compiler at work. I will find out if there is any free compiler so that I can test. |
@jackpoz I merged recent dev version of this repository to your pull request branch, and it works fine. |
Glad to hear :) maybe write your feedback in the PR too, it will help the PnP team decide when to merge it :) |
Commented under the pull request. Thanks for the fix. |
Reporting an Issue or Missing Feature
Issue
Expected behavior
Add-PnpFile should successfully upload file to the specified folder
Actual behavior
Only if a user is an owner of the site add-pnpfile works. Even though the user is given full control to the document library.
Steps to reproduce behavior
Connect-PnPOnline -Url 'the_sharepoint_url'
Add-PnPFile -Path test.txt -Folder 'the_document_library'
Which version of the PnP-PowerShell Cmdlets are you using?
What is the version of the Cmdlet module you are running?
3.17.20
How did you install the PnP-PowerShell Cmdlets?
one user who is an owner of the site, pnp-addfile works, the owner's permission on the document library is as follows:
the other user who has identical permission on the document library got permission denied when using add-pnpfile:
The text was updated successfully, but these errors were encountered: