Can we add users, sharepoint groups, Office 365 groups & Security groups using ListItemAllFields.AddRoleDefinitionAsync() #1103
Answered
by
jansenbe
mvcsharepointdev
asked this question in
Q&A
-
I have this code to add a user to a folder permission:-
but my question is can we add users, sharepoint groups, Office 365 groups & Security groups using ListItemAllFields.AddRoleDefinitionAsync()? or this is limit to certain types only ? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
jansenbe
Feb 21, 2023
Replies: 1 comment
-
@mvcsharepointdev : you can add all, you just need to ensure the "user" first. See https://pnp.github.io/pnpcore/using-the-sdk/security-users.html for more details. So for example before you can use an Azure AD group you do var myGroupToUse = await context.Web.EnsureUserAsync($"c:0t.c|tenant|{groupid}"); Then you use myGroupToUse.Id to actually add the group |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mvcsharepointdev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mvcsharepointdev : you can add all, you just need to ensure the "user" first. See https://pnp.github.io/pnpcore/using-the-sdk/security-users.html for more details. So for example before you can use an Azure AD group you do
Then you use myGroupToUse.Id to actually add the group