4

I want to check if a user is a site collection administrator of a particular site collection. When I go through the member functions I see two functions

site.CheckForPermissions(SPReusableAcl acl, SPBasePermissions perms)
site.DoesUserHavePermissions(SPReusableAcl acl, SPBasePermissions perms)

But how to use them? What is SPReusableAcl? How can I relate SPUser and SPReusableAcl?

Any ideas?

NLV
  • 21,141
  • 40
  • 118
  • 183

1 Answers1

9

Do you know about the .isSiteAdmin Property? You can check if the current user is admin by using

SPContext.Current.Site.RootWeb.CurrentUser.IsSiteAdmin

Also check out the SPWeb.SiteAdministrators collection.

Actually there are some nice suggestions on how to check if a user is site collection administrator here.

Dennis G
  • 21,405
  • 19
  • 96
  • 133
  • So just checking the permissions against the RootWeb is same as checking against the site collection? – NLV Dec 15 '10 at 10:24
  • 2
    Well yes and no, if your site collection administrators are ONLY added to the site you won't find them on the RootWeb - check the link. Easier is going for the `SPWeb.SiteAdministrators` collections and check whether your wanted user is in there. – Dennis G Dec 15 '10 at 11:41