Get User Group Collection in Sharepoint 2013

User Group Collection in SharePoint 2013:-

Before to get user group collection in SharePoint I would like to explain about the SharePoint group and permissions. SharePoint group are the collection of resources. Each group has its own permission. Below is code to Read User Group Collection in SharePoint 2013.

[AdSense-A]

public SPGroupCollection GetUserGroupCollection() //get current user group collection
{

SPGroupCollection userGroups;
using (SPSite site = new SPSite(PWAPath))
{
SPWeb web = site.OpenWeb();
userGroups = web.CurrentUser.Groups;
}
return userGroups;

}

// Read All Sharepoint Group

public SPGroupCollection GetAllSharepointGroup()  //Get All SharePoint group
{
SPGroupCollection userGroups;
using (SPSite site = new SPSite(PWAPath))
{
SPWeb web = site.OpenWeb();
userGroups = web.Groups;
}
return userGroups;
}

 


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!