SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a document library which does not inherit the site's permissions ('Custom permissions' is set).

How do I find out who has administrator permissions to this library, using C#?

share|improve this question

I believe the function you're looking for is SPList.DoesUserHavePermissions

Here is a slightly modified version of the example on that page, which may do what you need:

using (SPSite site = new SPSite("http://your/site/here"))
   SPBasePermissions perms = SPBasePermissions.ManageLists;

   string listUrl = site.RootWeb.RootFolder.ServerRelativeUrl + "Your Document Library Name";
   SPList list = site.RootWeb.GetList(listUrl);

   // Be sure the current user has permission to check permissions.
   if (site.RootWeb.DoesUserHavePermissions(SPBasePermissions.EnumeratePermissions))
      foreach (SPGroup group in site.RootWeb.Groups)
         foreach (SPUser user in group.Users)
            // Check another user's permissions.
            bool hasPermission = list.DoesUserHavePermissions(user, perms);
            Console.WriteLine("{0, -5}  {1}", hasPermission, user.LoginName);
share|improve this answer
Side note: Never put a using around a site's RootWeb, it will cause exceptions. Pretty much the rule of thumb is: if you "own" (i.e. created) the disposable object, then dispose it. If it is created by the SharePoint API, don't – Colin Mar 18 '12 at 3:07
@Colin: Good call. I should've spotted that error in the example. I've updated the code accordingly. – Stuart Pegg Mar 19 '12 at 13:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.