I have experienced many legacy solutions which closely depend on the SharePoint Server Side Object Model (SSOM). This was the only option for being able to manage your SharePoint 2007 and 2010 farms. You may have read on some of my past blog posts, code written against the SharePoint SSOM is extremely difficult to unit test without Microsoft Fakes or writing a facade. As a result, I have deepened my familiarity with the SharePoint 2013 REST APIs. They are much more strategic, especially when planning for the possibility of moving to SharePoint Online / Office 365.
While working on permissions management within SharePoint, I needed to identify when a user first obtained access to their SharePoint 2013 site. I typically look at the
SiteUsers table for information relating to users against a Site Collection. The
SiteUsers collection can be accessed via the SharePoint REST API by going to
/_api/web/SiteUsers. However, the properties on each
SiteUser look like the following (obtained from the Users, groups, and roles REST API Reference):
There are no dates in this. When I thought about it, I remembered the User Information List. This list contains a wealth of additional details beyond what the
SiteUsers collection provides. The reason: it is nothing more than a list - just one with lots of columns of rich data. More importantly, it is available to query via the REST API! Checking the structure of the User Information List was as simple as executing the following REST query:
Note: a short way is via
/_api/web/SiteUserInfoList. The results are as follows:
Awesome! It exists! Now all I have to do is query for the specific user that I want. When I have a specific UserName to find, all I have to execute is the following query:
And I get exactly what I want:
In summary, when you are looking to find information about users whom have access to your SharePoint sites, remember the User Information List, and also remember it is queryable via the REST API!