savan patel

savan patel

  • NA
  • 14
  • 3.4k

Get users of current sitecollection from User Information Li

Apr 16 2015 2:59 AM
I have "User Information List" and i want to get user of current site collection only but it is fetching all users of Farm.

Below is the code.

SPSite currentSite = SPContext.Current.Site; SPWeb web =currentSite.OpenWeb();
SPUserCollection userCollection = web.SiteUsers;
SPList userList = web.Lists.TryGetList("User Information List");
if (userList != null)
{
foreach (SPListItem item in userList.Items)
{
}
}

Not sure what i am doing wrong ! Any thoughts on this ??

Answers (1)