1

I need to remove all the groups with unique permissions from a sharepoint online list, without knowing their names, just removing them all, role inheritance is already broken at this point, what is the fastest way to achieve this?

enter image description here

Like doing that

EDIT: Via C# CSOM, forgot to specify

1

I managed to do it myself, code:

public void RemovePermissionsFromList(string url, string listName)
    {
        using (var ctx = new ClientContext(url))
        {
            ctx.Credentials = new SharePointOnlineCredentials(Username, Password);

            List list = ctx.Web.Lists.GetByTitle(listName);
            ctx.Load(list, l => l.RoleAssignments.Include(r => r.Member));
            ctx.ExecuteQuery();

            foreach (var group in list.RoleAssignments)
            {
                list.RoleAssignments.GetByPrincipal(group.Member).DeleteObject();
            }

            ctx.ExecuteQuery();
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.