I normally use ClientContext
to connect to SharePoint and use SiteUserInfoList
to retrieve the list of SharePoint users. (I need to copy the data into an SQL Server database.) Disappointingly, this does not return all users in SharePoint. Specifically I am missing users that originate from another company; most likely there's some kind of security setting that prevents my user from seeing their data.
However, when I retrieve one of the lists I require, "Applications", I do get entries where these missing users are referenced, e.g. one of them is a DTSupplyAccountable
of an Application. I only get a SharePoint ID, e.g. 265, and since I don't have a user with that ID I lack vital data about this Application.
Our SharePoint support recommended that I use the REST API instead to retrieve the data I need. Since there is no budget (or time) to rewrite the entire application, I've decided to use the REST API only to "plug the holes".
I was pleased to discover that calling _api/Web/SiteUsers
gives me a far more complete list than SiteUserInfoList
(see above). Yet this solution is imperfect: the resulting dataset lacks several properties I need:
- FirstName
- LastName
- Department
Admittedly, I can retrieve these by calling _api/web/lists/GetByTitle('Applications')/items(7)?$select=DTSupplyAccountable/Id,DTSupplyAccountable/FirstName,DTSupplyAccountable/LastName,DTSupplyAccountable/Department,DTSupplyAccountable/Title,*&$expand=
DTSupplyAccountable
, but considering that I need to do this for dozens of users and considering the "inelegance" of this solution, I would much rather find another way to do this.
Is there any possibility that I can add parameters to SiteUsers
to retrieve the missing properties?