SPList.GetUserEffectivePermissions method

Gets the effective permissions that a specified user has on the list.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public override SPBasePermissions GetUserEffectivePermissions(
	string userName


Type: System.String

The name the user whose permissions are to be returned.

Return value

Type: Microsoft.SharePoint.SPBasePermissions
A bitwise combination of enumeration values that specifies a set of permissions.


The current user does not have the permission to enumerate permissions.

The following example is a console application that enumerates all the users in all the groups of a website, checking whether each user has the ApproveItems permission on the Shared Documents library. For an example showing another approach to the same task, see the DoesUserHavePermissions(SPUser, SPBasePermissions) method.

using System;
using Microsoft.SharePoint;

namespace Test
    class Program
        static void Main(string[] args)
            using (SPSite site = new SPSite("http://localhost"))
                using (SPWeb web = site.OpenWeb())
                    // Get a list to check permissions on.
                    string listUrl = web.RootFolder.ServerRelativeUrl + "shared documents";
                    SPList list = web.GetList(listUrl);

                    // Be sure the current user has permission to check permissions.
                    if (web.DoesUserHavePermissions(SPBasePermissions.EnumeratePermissions))
                        foreach (SPGroup group in web.Groups)
                            foreach (SPUser user in group.Users)
                                // Get the rights mask for a user.
                                SPBasePermissions permMask = list.GetUserEffectivePermissions(user.LoginName);

                                // Check if the user has a specific right.
                                bool hasPermission = (permMask & SPBasePermissions.ApproveItems) != 0;
                                Console.WriteLine("{0} {1} permission to approve items.", 
                                                  user.LoginName, hasPermission ? "has" : "does not have");
            Console.Write("\nPress ENTER to continue...");