1
Answer

Get users of current sitecollection from User Information Li

savan patel

savan patel

9y
732
1
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)