Thursday, March 17, 2016

Query User Information List gives :Error 404 List Not found- SharePoint 2013

Being a SharePoint developer we all know that 
The User Information List stores information about a user by having some metadata set up for the user. Some examples are Picture, Email, DisplayName, LoginName etc. ) This list is only visible to and accessible by administrators.
However today we faced very weird issue that not able to access this hidden list. we can browse it under "/_catalogs/users" but we were not able to query it

Problem : 
 We were not able to query the User Information List in SharePoint 2013 On-Premise.
Tried following stuffs :
1. http://your-site-name/_vti_bin/ListData.svc/UserInformationList
2. http://your-site-name//_api/web/lists/GetByTitle(‘User Information List')
3. In PowerShell - 
$SITE = GET-SPSITE "HTTPS://your-site-name"
$WEB = $SITE.ROOTWEB

$LIST = $WEB.LISTS["USER INFORMATION LIST"]
All the above was giving the 404 error, List was not exist under the $web.Lists - which was very weird.
Solution:
After some r&d found the way to access it using SiteUserInfoList object

$web.SiteUserInfoList.Items
using this we can get the items of User information list.

Happy Coding!