15 February 2007

How do I? – Get a list of all users for each SharePoint site


If you're doing an upgrade of an existing SharePoint Portal Server 2003 farm to Microsoft Office SharePoint Server 2007 you will undoubtedly run into the need to identify all site administrators in your SPS 2003 environment. If for no other reason than to notify them that their Themes will be lost during the migration to MOSS 2007, you'll be in contact with these administrators.
The question is… how do you identify all the site administrators? If you only have a hand full of sites, it can certainly be done manually, but if you dealing with a huge farm and thousands of sites, this is not practical. That is exactly where TSQL comes to the rescue.
Now as you know, we are not allowed to directly update any of the SharePoint databases as this action would invalidate your support agreement with Microsoft and put your portal in an unsupported state. That doesn't mean we can't read from it. This little SQL query will deliver the results you are looking for:
USE SharePoint_SITESELECT w.fullurl, w.title, u.tp_title, u.tp_loginFROM webs w, userinfo u, webgroups gINNER JOIN webgroupmembership pON g.webid = p.webidAND g.id = p.groupidWHERE g.type 5AND u.tp_id = p.memberidAND u.tp_siteid = g.siteidAND w.id = g.webidAND w.siteid = g.siteidORDER BY w.fullurl
The WebGroups table defines all the web sites and they groups that was created for each. Joining it to the WebGroupMembership table provides us with the users that belong to the groups and from there we just have to get more user information and web site information from the UserInfo and Webs tables.
If you wish to get a list of other standard user groups, just change the "g.type =" part of the statement as follows:
  1. Guest
  2. Reader
  3. Contributor
  4. Web Designer
  5. Administrator
Once you have the list, you can dump it to a .CSV file and manipulate it from Excel.

You could also download my SQL script here.
Later
C

No comments:

Post a Comment

Comments are moderated only for the purpose of keeping pesky spammers at bay.

SharePoint Remote Event Receivers are DEAD!!!

 Well, the time has finally come.  It was evident when Microsoft started pushing everyone to WebHooks, but this FAQ and related announcement...