I have a number of queries that I use to manage SharePoint an I wanted to share a few of the more useful ones. On one large portal, there is a proliferation of Sub-Areas which are managed by a number of different users in several different companies. Some of these areas use unique permissions extensively and it has become difficult to keep track of who has what permissions. I use this query to list out the portal structure and show which users and groups have what permissions on the area. This query also makes use of the function I wrote about in a previous article which decodes the portal permissions.
DECLARE @SiteRoot VARCHAR(255)
DECLARE @AreaNav VARCHAR(4000)
SET @SiteRoot = ‘http://localhost/’
SET @AreaNav = ‘Topics’ SELECT
@SiteRoot + Webs.FullUrl + ” AS [URL]
, @SiteRoot + Webs.FullUrl + ‘/_layouts/1033/spcatsec.aspx?CatID=’
+ convert(varchar(255), CatPath.CatID) as [Manage]
, case CatDef.InheritSecurity
WHEN 1 then ‘Inherits’
WHEN 0 then ‘Unique’
END AS [PermSetting]
, CatPath.Path AS [AreaNav]
, CASE WHEN MemberIsUser=0 and WebGroups.Title IS NULL THEN
(SELECT top 1 title
FROM webgroups
WHERE siteid=Webs.siteid and id=portalperm.UserGroupID)
ELSE ISNULL(WebGroups.Title ,UserInfo.tp_Login)
END AS [GroupOrUser]
, ISNULL(WebGroups.[description],SharePointHelper.dbo.sFn_DecodePermMask(PortalPerm.PortalMask)) AS [Rights]
FROM
webs
LEFT OUTER JOIN CatDef
ON replace( CatDef.weburl,’*’,”) = Webs.fullurl
LEFT OUTER JOIN CatPath
ON CatDef.catid=CatPath.catid
LEFT OUTER JOIN portalperm
ON portalperm.permid=CatPath.permid
LEFT OUTER JOIN WebGroups
ON (portalperm.UserGroupID = WebGroups.[id] and WebGroups.webid=Webs.[id])
LEFT OUTER JOIN userinfo
ON (portalperm.UserGroupID= UserInfo.tp_ID) and (UserInfo.tp_SiteID=Webs.siteid)
WHERE (CatPath.Path IS NOT NULL) and ( CatPath.Path like ‘%’ + @AreaNav + ‘%’)
ORDER BY CatPath.Path, [GroupOrUser], userinfo.tp_login
The abridged output looks similar to this:
http://localhost/Topics | Inherits | :Home:Topics | Administrator | Has full control of the Web site. |
http://localhost/Topics | Inherits | :Home:Topics | Content Manager | V Ar; V Pg; A Itm; Ed Itm; Del Itm; Mg Per Vws; A/D Per Wb Prts; Up Per Wb Prts; Cncl Chck; A/Mod Pgs; Crt Ar; Mg Ar; Brw Dr; |
http://localhost/Topics | Inherits | :Home:Topics | Contributor | Can add content to existing document libraries and lists. |
http://localhost/Topics | Inherits | :Home:Topics | Member | V Ar; V Pg; A Itm; A/D Per Wb Prts; Up Per Wb Prts; |
http://localhost/Topics | Inherits | :Home:Topics | Reader | Has read-only access to the Web site. |
http://localhost/Topics | Inherits | :Home:Topics | Web Designer | Can create lists and document libraries and customize pages in the Web site. |
http://localhost/Divisions | Unique | :Home:Topics:Divisions | Administrator | Has full control of the Web site. |
http://localhost/Divisions | Unique | :Home:Topics:Divisions | Content Manager | V Ar; V Pg; A Itm; Ed Itm; Del Itm; Mg Per Vws; A/D Per Wb Prts; Up Per Wb Prts; Cncl Chck; A/Mod Pgs; Crt Ar; Mg Ar; Brw Dr; |
http://localhost/Divisions | Unique | :Home:Topics:Divisions | Contributor | Can add content to existing document libraries and lists. |
http://localhost/Divisions | Unique | :Home:Topics:Divisions | Member | V Ar; V Pg; A Itm; A/D Per Wb Prts; Up Per Wb Prts; |
http://localhost/Divisions | Unique | :Home:Topics:Divisions | PBCVjohn | V Ar; V Pg; A Itm; Ed Itm; Del Itm; Mg Per Vws; A/D Per Wb Prts; Up Per Wb Prts; Cncl Chck; A/Mod Pgs; Crt Ar; Mg Ar; A Styl; Brw Dr; |
http://localhost/Divisions | Unique | :Home:Topics:Divisions | Reader | Has read-only access to the Web site. |
http://localhost/Divisions | Unique | :Home:Topics:Divisions | Web Designer | Can create lists and document libraries and customize pages in the Web site. |