Retrieve all user in SharePoint 2010 site using Javascript client object model

To List out all the users in a site or web an easy way is to access the User Information list of the current site or web.

Here is a short example of how to get it

function GetAllUsers()
{
var clientContext = new SP.ClientContext.get_current();

var web = clientContext.get_web();

var userInfoList = web.get_siteUserInfoList();

this.collListItem = userInfoList.getItems();

clientContext.load(collListItem);

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args)
{

var item = collListItem.itemAt(0);

var profileNotes = item.get_item(‘Notes’);
alert(profileNotes);
}
function onQueryFailed(sender, args)
{
}
}

Related Posts

Disclaimer: The contents of this site are provided “AS IS”. Information and views expressed including URL(s) and other Internet website references, may change without notice. You bear the risk of using it. SharePoint, MOSS, SharePoint 2010, SharePoint 2013 and Microsoft are trademarks of the Microsoft Corporation.Learning SharePoint only provides Tips,Tricks and Tutorials for using Microsoft SharePoint, Microsoft Office and related Softwares.
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.