Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How to Retrive All Groups in SharePoint Programmatically
WhatsApp
Gowtham Rajamanickam
9y
4.5
k
0
0
25
Blog
Steps
Open Visual Studio in your system
Select Console Applciation template and give as name .
Add a Microsoft.Cleint Assembly refrence file in right side refrence tab in visual studio.
Replace Program.cs with the source code
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
Microsoft.SharePoint.Client;
using
System.IO;
namespace
CSOMCodeSamples
{
class
Program
{
static
void
Main(
string
[] args)
{
// ClientContext - Get the context for the SharePoint Site
ClientContext clientContext =
new
ClientContext(
"http://gauti.sharepoint/sites/CSOM/"
);
// Get the SharePoint web
Web web = clientContext.Web;
// Get all the site groups
GroupCollection groupColl = web.SiteGroups;
clientContext.Load(groupColl);
// Execute the query to the server
clientContext.ExecuteQuery();
// Loop through all the groups
foreach
(Group group
in
groupColl)
{
// Display the group name
Console.WriteLine(group.Title);
}
Console.ReadLine();
}
}
}
Hit F5 and check the output .
Retrive all groups in sharepoint
SharePoint Groups
Up Next
Programmatically Check whether Current Logged in User is a Member of SharePoint User Group or Not
Ebook Download
View all
SharePoint Framework (SPFx) A Developers Guide
Read by 11.1k people
Download Now!
Learn
View all
Membership not found