2

I know we can create SPGroup and also delete it. But is it possible to disable it? I want this, because, I want to re-enable it later. I don't want to delete and re-create it, because, there could be users in the group and the group would have been part of permissions for certain lists / libraries. Once an SPGroup is disabled, users in that group won't be able to do anything. Is this achievable? If so, can anyone please provide some pointers?

0

If you don't want the members of a group to be able to "do" anything, you can simply change the permission level of the group temporarily.

Create a permission level
Site settings > Site permissions > from the Ribbon choose Permission Levels > Add a Permission Level. Then choose what you want your users to be able to do.

Assign the new permission level to your group
Site settings > Site permissions > select your group > from the Ribbon choose Edit User Permissions > select your newly created permission level > OK

Then, when you're ready, change the permission level back to what it was originally.

  • I can't do this, because, I have no way of way knowing what it was originally set to. – Ven Oct 21 '15 at 10:16
  • Are you trying to do this programmatically? – Submits Oct 21 '15 at 15:23
  • Yes. I need to do it programmatically, – Ven Oct 22 '15 at 10:18
  • You could save the original permission level in a separate list or in a text file in one of the libraries or in the file system on the SharePoint server. So do what I suggested programmatically, save the permission level to the list or file. Then, when you're ready, get the permission level from the list or file and set it back to the group. – Submits Oct 22 '15 at 10:27
0

I run some PowerShell to see the definition of a Group.

Name                            : Approvers
LoginName                       : Approvers
Owner                           : Dev Portal Owners
Users                           : {....}
Description                     : Members of this group can edit and approve 
                                  pages, list items, and documents.
DistributionGroupEmail          : 
DistributionGroupAlias          : 
DistributionGroupErrorMessage   : 
Xml                             : <Group ID="13" Name="Approvers" 
                                  Description="Members of this group can edit 
                                  and approve pages, list items, and 
                                  documents." OwnerID="6" OwnerIsUser="False" 
                                  />
ID                              : 13
DistributionGroupPendingJobData : 
OnlyAllowMembersViewMembership  : True
AllowMembersEditMembership      : False
AllowRequestToJoinLeave         : False
AutoAcceptRequestToJoinLeave    : False
RequestToJoinLeaveEmailSetting  : 
CanCurrentUserViewMembership    : True
CanCurrentUserEditMembership    : True
CanCurrentUserManageGroup       : True
ContainsCurrentUser             : True
ExplicitlyContainsCurrentUser   : True
ParentWeb                       : Dev Portal
Roles                           : {Approve}
IsHiddenInUI                    : False

Now it seems to me that there is now way to disable a group. I found a property named IsHiddenInUI and tried to set it false. Unfortunately, IsHiddenInUI is a Read-Only property. So I think your solution is: delete and re-create group.

  • As I mentioned earlier, if I delete and recreate, what will happen to those items/documents, which had been assigned to this Group? There is no way to maintain the original / initial settings before the delete. – Ven Oct 21 '15 at 10:46
  • You have to assign this group to items/documents again! – Atish Dipongkor - MVP Oct 21 '15 at 10:57
0

How about using REST api or CSOM to check if the user is in a particular group and make your decision accordingly. This way you keep your group but in your code do all the required validation to allow or block users in that group from doing something.

  • But how do I know, if a group is disabled or not. – Ven Oct 22 '15 at 10:20
  • I gather from your question that your objective is to allow or block users in a group from accessing something in your site. I dont know what your business rules are for enabling/disabling group's access to the site but all you need is a flag such as "Disabled" and you can put that in the group description field or keep a lookup list separatley for that. Your REST/CSOM code can use that lookup to make a decision. – HarryB Oct 22 '15 at 10:52

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.