-
Notifications
You must be signed in to change notification settings - Fork 333
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
Enhances spo folder roleassignment
commands with Microsoft Entra groups, Closes #6196
#6500
Conversation
spo folder roleassignment
commands with Microsoft Entra groups, Closes #6196
Thanks Nico, We'll try to review it ASAP! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicodecleyre awesome work 👏
I added a few comment I may resolve during merging or if you have time and want to help out then awesome.
I should merge this within few days
Checked locally and all fine.
|
||
`--groupName [groupName]` | ||
: The Microsoft Entra or SharePoint group name. Specify either `upn`, `groupName` or `principalId` but not multiple. | ||
: The Microsoft Entra or SharePoint group name. Specify either `upn`, `groupName`, `principalId`, `entraGroupId` or `entraGroupName` but not multiple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should correct that now it relates to SharePoint Group only so we should dropt the first part and maybe leave it like
: The Microsoft Entra or SharePoint group name. Specify either `upn`, `groupName`, `principalId`, `entraGroupId` or `entraGroupName` but not multiple. | |
: The SharePoint group name to add. Specify either `upn`, `groupName`, `principalId`, `entraGroupId` or `entraGroupName` but not multiple. |
Add the role assignment to the specified folder based on the Entra Group Id and role definition id. | ||
|
||
```sh | ||
m365 spo folder roleassignment add --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --folderUrl "/Shared Documents/FolderPermission" --entraGroupId '27ae47f1-48f1-46f3-980b-d3c1470e398d' --roleDefinitionId 1073741827 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets use double quotes to be consistent
m365 spo folder roleassignment add --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --folderUrl "/Shared Documents/FolderPermission" --entraGroupId '27ae47f1-48f1-46f3-980b-d3c1470e398d' --roleDefinitionId 1073741827 | |
m365 spo folder roleassignment add --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --folderUrl "/Shared Documents/FolderPermission" --entraGroupId "27ae47f1-48f1-46f3-980b-d3c1470e398d" --roleDefinitionId 1073741827 |
|
||
`--groupName [groupName]` | ||
: The Microsoft Entra or SharePoint group name. Specify either `upn`, `groupName` or `principalId` but not multiple. | ||
: The Microsoft Entra or SharePoint group name. Specify either `upn`, `groupName`, `principalId`, `entraGroupId` or `entraGroupName` but not multiple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets clarify that this should be used only for SPO groups
: The Microsoft Entra or SharePoint group name. Specify either `upn`, `groupName`, `principalId`, `entraGroupId` or `entraGroupName` but not multiple. | |
: The SharePoint group name to add. Specify either `upn`, `groupName`, `principalId`, `entraGroupId` or `entraGroupName` but not multiple. |
Remove the role assignment from the specified folder based on the Entra group id. | ||
|
||
```sh | ||
m365 spo folder roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --folderUrl "/Shared Documents/FolderPermission" --entraGroupId '27ae47f1-48f1-46f3-980b-d3c1470e398d' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets use double quotes
m365 spo folder roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --folderUrl "/Shared Documents/FolderPermission" --entraGroupId '27ae47f1-48f1-46f3-980b-d3c1470e398d' | |
m365 spo folder roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --folderUrl "/Shared Documents/FolderPermission" --entraGroupId "27ae47f1-48f1-46f3-980b-d3c1470e398d" |
let group: Group; | ||
if (args.options.entraGroupId) { | ||
group = await entraGroup.getGroupById(args.options.entraGroupId); | ||
} | ||
else { | ||
group = await entraGroup.getGroupByDisplayName(args.options.entraGroupName!); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets simplify
let group: Group; | |
if (args.options.entraGroupId) { | |
group = await entraGroup.getGroupById(args.options.entraGroupId); | |
} | |
else { | |
group = await entraGroup.getGroupByDisplayName(args.options.entraGroupName!); | |
} | |
const group = args.options.entraGroupId | |
? await entraGroup.getGroupById(args.options.entraGroupId) | |
: await entraGroup.getGroupByDisplayName(args.options.entraGroupName!) |
@@ -1,3 +1,4 @@ | |||
import { Group } from '@microsoft/microsoft-graph-types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we simplify the code as I suggested we may remove this one
import { Group } from '@microsoft/microsoft-graph-types'; |
} | ||
|
||
await this.breakRoleAssignment(requestUrl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woooot this command not only adds role assignment but breaks inheritance if it was not broken 😮
TBH I was not aware of it and the command description does not mention it I think.
@pnp/cli-for-microsoft-365-maintainers I think it was our mistake and it is a bug as we have separate command for breaking role inheritance and no other role assignment command for either file or list o list item will break the role inheritance.
@@ -1,3 +1,4 @@ | |||
import { Group } from '@microsoft/microsoft-graph-types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we simplify the if we may remove this import
import { Group } from '@microsoft/microsoft-graph-types'; |
let group: Group; | ||
if (args.options.entraGroupId) { | ||
group = await entraGroup.getGroupById(args.options.entraGroupId); | ||
} | ||
else { | ||
group = await entraGroup.getGroupByDisplayName(args.options.entraGroupName!); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets simplify
let group: Group; | |
if (args.options.entraGroupId) { | |
group = await entraGroup.getGroupById(args.options.entraGroupId); | |
} | |
else { | |
group = await entraGroup.getGroupByDisplayName(args.options.entraGroupName!); | |
} | |
const group = args.options.entraGroupId | |
? await entraGroup.getGroupById(args.options.entraGroupId) | |
: await entraGroup.getGroupByDisplayName(args.options.entraGroupName!); |
Ready to merge 🚀 I should perform small fixups when merging |
Merged manually. Thank you for your awesome contribution. You Rock 🤩👏 |
Closes #6196