O365 Site Collection Users List

Recently I was in a need to get a list of all the users from a list of O365 Site Collections and I thought of following approaches to do this:

Approach 1:

  1. Get a list of site collections in a CSV
  2. Loop through them one by one
  3. From each site collection get a list of groups
    and download users in it
  4. There will be other users added directly to the
    site collection. In that case get the user from each web directly.

But there are many gotchas with
this approach:

  1. What if user has broken permissions to a page or
    library and added user(s) directly to that?
  2. Same goes with a subsite

Approach 2:

  1. We know that every site collection has a User
    Information List, which is hidden
  2. You can access it appending ‘/_catalogs/users/simple.aspx’
    to your site collection
  3. Every user added to the site collection, no matter
    where, it will go and sit in the User Information List at the Site Collection
    level
  4. Simplistically thinking the User Information List
    is just another SharePoint list. You can access it using the Web object as Web.SiteUserInfoList

Therefore, approach 2 seemed more appropriate and can be
achieved in quick time. You can access the code here.

If you liked the article, share it with your friends and colleagues. You can also send a “Thank you” note by buying me a coffee. Buy Me a Coffee

Leave a Comment

Your email address will not be published. Required fields are marked *