-
Notifications
You must be signed in to change notification settings - Fork 331
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
Bug report: Cannot add an owner to a site if I don't have access to the site already #4600
Comments
I think it should be possible for both owners of the site and admin users. Perhaps we have to add an |
We would still need to check if the site is a group or not though... By the way I think the command seems to almost always need admin privileges, so an extra flag should not be necessary. |
Can it be an option to use the graph batch api to add an owner to a site where you don't have access to? POST https://graph.microsoft.com/v1.0/$batch
|
The point is that we dont have the groupId yet. As soon as we would have it, the current implementation works fine, I believe. |
Got it, then we can use this api: POST https://tenant-admin.sharepoint.com/_api/SPO.Tenant/RenderAdminListData data:
But it would need an accesstoken for the admin site resource though |
We could also reuse |
Well, you need to add the xml envelope specific to this endpoint.... (check out |
I tried to use the xml envelope in combination with the the data:
|
Also noticed we can do a get request to get the group id:
|
This seems to work regarding the
But it doesn't seem to recognize the SiteId property (tried to show all the properties but it doesn't show a site id either.. 😞) |
Maybe just an id? It should have one, although it might be named different.. |
doesn't seem so.. The same goes for |
Hi @nicodecleyre, the only thing that I'm slightly concerned about with this way of doing things is the 5000-item 'limit' on SharePoint. With the tenant endpoint, SP will take care of loading and filtering. If we do it ourselves using this list, we might run into these annoying errors with large tenants. |
Let's stick then with the first option and use |
Does it contain a SiteId? |
Yes |
Ok, interesting, does it allow to Maybe we could check how the output relates to the current spo site list output. We might move this into a util function and use it in both places. For example: |
No, it ignores the
Also no, the properties the 2 api's return don't match 100%. The |
By the way, out of curiosity, are you sure Aside from that, I agree with you that we should use the wrapper endpoint, as it's used by the SP user interface as well and as it contains the correct properties.
In that case: let's leave the
I like this idea. Also, because that will remove the need to use |
@pnp/cli-for-microsoft-365-maintainers any comments on the renewed specs, based on the discussion? |
Thanks for the research @nicodecleyre! |
No official documentation found regarding that. Only that it's the recommended approach when retrieving info from large lists and some blog posts that say it can handle the threshold limit |
first of all sorry for the late response 🙏 |
let's get this shipped! |
Something I can work on? |
Sure @nicodecleyre! |
Description
Some time ago we refactored the
spo site classic set
into thespo site set
command and combined group site and regular site setting operations.This has resulted in an issue. We can no longer set owners for a site if we are currently not an owner or site member of that site.
In other words, if I am a SharePoint administrator, I sometimes want to give myself access to site collections using scripts. But now I cannot.
This command is affected:
https://pnp.github.io/cli-microsoft365/cmd/spo/site/site-set/
The reason for this situation is that the CLI first tries to retrieve if the site is a Group or not, right here
It does that using the site specific api, which it cannot access because the logged in user has no access yet.
I'm not sure how we should fix this yet. We had some thoughts on specific CRUD actions for Sitecollection admins, but these are currently nowhere near completion: #4173
What we could do is start using the tenant api to get the site details, (just like
spo site list
)Steps to reproduce
Try to add your own account as an owner to a site you have no access to:
Implementation
We've decided to switch from the
/sites/somesite/_api/site
to use an admin API. We'll want to use the following API call to fetch the right information:POST https://tenant-admin.sharepoint.com/_api/SPO.Tenant/RenderAdminListData
data:
We'll want to place this functionality in a util function, so we can reuse it in other places. I'd suggest we add the following function to the
spo.ts
util function:The text was updated successfully, but these errors were encountered: