Create a contact list with the user information list
-
28-09-2020 - |
Question
I want to populate a list in sharepoint 2013 foundation with the user information list. The user information list is found at /_catalogs/users/simple.aspx (SiteUserInfoList) and contains all the entries of the users.
Any idea about how to do this?
OTHER TIPS
The url provided is basically a oob list that contains all the user information. That means you can fetch an instance of it and perform normal list operations with it.
If using server object model, this is the code I lifted from Code Project and modified.
SPUser sUser = myweb.CurrentUser;
SPList UserList = SPContext.Current.Web.SiteUserInfoList;
SPList targetList = SPContext.Current.Web.Lists["target"];
foreach(SPListItem item in UserList.Items.GetItems())
{
var newItem = targetList.Items.Add();
newItem["UserName"] = item.Name;
//populate column values;
newItem.Update();
}
If you want to use different object model then there is comphrensive guide to working with list and list items using different object models : Here
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange