Fetch all user using Auto-hosted apps in SharePoint Online 2013

InfoPath alternatives for form designing SharePoint

In this post, we will discuss how to fetch all users using Auto-Hosted apps in SharePoint online 2013.

Also you can check out:

Create Approval workflow using SharePoint Designer in SharePoint foundation 2010

Task assigned to user or current user groups in SharePoint 2010 using CAML query

– Provider Hosted App in SharePoint Online using Visual Studio 2017 + Deploy Provider Hosted Add-in to Microsoft Azure

1. First I created Auto-hosted apps using visual studio 2013.

2. I added one level in Default.aspx for showing the users name.

<asp:Label ID=”UserName” runat=”server”></asp:Label>

3. Now I added the following code under Default.aspx.cs (code behind code)

using (var clientContext = spContext.CreateUserClientContextForSPHost())

{

List UserInformationList = clientContext.Web.Lists.GetByTitle(“User Information List”);

CamlQuery query = CamlQuery.CreateAllItemsQuery(100);

Microsoft.SharePoint.Client.ListItemCollection items = UserInformationList.GetItems(query);

clientContext.Load(items);

clientContext.ExecuteQuery();

foreach (Microsoft.SharePoint.Client.ListItem listItem in items)

{

UserName.Text = UserName.Text + “, ” + listItem[“Title”];

}

}


4. Now I Save and deploy this apps in my SharePoint Online site.

 Fetch all user using Auto-hosted apps in SharePoint Online 2013
Fetch all user using Auto-hosted apps in SharePoint Online 2013

5. Now I am able to see all user in my SharePoint Online site. See in fig


You May Also like the Following SharePoint Online Tutorials:

About Navneet Singh

I am Navneet Singh, Working at C3it software solutions pvt. ltd. in Pune. My core skills are SharePoint 2013, Office 365, SharePoint 2010, SharePoint Designer, SharePoint Designer Workflow, Nintex Workflow, Infopath, Webpart, CSOM/SSOM, Power-shell, C#, ASP.NET and SQL Server.

View all posts by Navneet Singh →

Leave a Reply