In this article we explore the Server Object Model for dealing with Groups and Users inside SharePoint.
Our Intent
We intend to create a webpart that displays the users & groups in the SharePoint site.
For example:
Group 1
- User 1
- User 2
Group 2
- User 3
- User 4
The Solution
Create a new SharePoint solution and add a new webpart into it. Place a literal control over it, as in:
In the Page Load event add the following code:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
RefreshData();
}
private void RefreshData()
{
StringBuilder sb = new StringBuilder("<h2>Groups & Users</h2></br>");


karthick rPosted Dec 7, 2017, 4:46 AM
Hi in my sharepoint 2013, i have 50 groups created but "SPContext.Current.Web.Groups " gives me only 27 groupnames only. can you help on this ?
Lajapathy ArunPosted Sep 3, 2012, 3:48 PM
Yes, looks pretty nice to read sharepoint :)
Jean PaulPosted Aug 23, 2012, 9:24 AM
I agree to Dinesh too.. Good idea Lajapathy.. I wanted to add that SharePoint has recorded growth in even the recession too.. More Java Documentum, other f/w got converted to SP. Plus there are 10x more aspects in SP compared to ASP.NET or other tehcnologies. So people loving learning knowledge this is an endless stream and we can enjoy everyday.
Dinesh BeniwalPosted Aug 23, 2012, 7:20 AM
That will be great Lajapathy.
Lajapathy AruneditedPosted Aug 23, 2012, 2:27 AMEdited Aug 23, 2012, 2:27 AM
Nice one :) going to start on Sharepoint.
Jean PauleditedPosted Aug 22, 2012, 10:36 PMEdited Aug 22, 2012, 10:36 PM
Hello Yazzy,I can provide the answer based on my understanding of your question. SharePoint 2010 is having its own content database in SQL Server 2008 R2. But it is not recommended way to delete data from the database.The recommend way is to use: 1) Server object model (which requires SharePoint binaries on the execution machineSPList list;more: http://jeanpaulva.com/2012/05/30/sharepoint-2010-sharepoint-object-model/2) Client object model (which do not requires SharePoint binaries on the execution machine. ClientContext context = new ClientContext(ServerText.Text); List list = context.Web.Lists.GetByTitle("Tasks");ListItemCollection listItems = list.GetItems(new CamlQuery() { ViewXml = "<View/>" }); context.Load(listItems); context.ExecuteQuery();listItems[listItems.Count - 1].DeleteObject(); context.ExecuteQuery();more: http://www.codeproject.com/Articles/399156/SharePoint-2010-Client-Object-Model-IntroductionYou can use either of the above to achieve the same.
yazzy yazzyPosted Aug 22, 2012, 10:10 PM
Hi, Please help. i have this project. the user is using Sharepoint 2010 web application (front end programming uses asp.net)to search data. The user can delete data in Sharepoint web application. However, the data can be deleted in the sharepoint database but it can never be deleted in the SQL server 2008 which is connected to the sharepoint. Is there any sharepoint built-in database in 2010? Do I use a list function? Please help with the coding.