GetUserEffectivePermissions returns wrong results

I’m checking the permissions for user on a SharePoint 2013 list:

using (var ctx = new ClientContext(“http://comtoso.com”))
{
var list = ctx.Web.Lists.GetByTitle(“TestList”);
ctx.Load(list);
ctx.ExecuteQuery();

var permissions = list.GetUserEffectivePermissions(@”domain\username”);
ctx.ExecuteQuery();

foreach (var permission in Enum.GetValues(typeof(PermissionKind)).Cast())
{
var permissionName = Enum.GetName(typeof(PermissionKind), permission);
var hasPermission = permissions.Value.Has(permission);
Debug.WriteLine(“Permission: {0}, HasPermission: {1}”, permissionName, hasPermission);
}
}

which returns following output:

Permission: EmptyMask, HasPermission: True
Permission: ViewListItems, HasPermission: False
Permission: AddListItems, HasPermission: False
Permission: EditListItems, HasPermission: False
Permission: DeleteListItems, HasPermission: False
Permission: ApproveItems, HasPermission: False
Permission: OpenItems, HasPermission: False
Permission: ViewVersions, HasPermission: False
Permission: DeleteVersions, HasPermission: False
Permission: CancelCheckout, HasPermission: False
Permission: ManagePersonalViews, HasPermission: False
Permission: ManageLists, HasPermission: False
Permission: ViewFormPages, HasPermission: True
Permission: AnonymousSearchAccessList, HasPermission: False
Permission: Open, HasPermission: True
Permission: ViewPages, HasPermission: False
Permission: AddAndCustomizePages, HasPermission: False
Permission: ApplyThemeAndBorder, HasPermission: False
Permission: ApplyStyleSheets, HasPermission: False
Permission: ViewUsageData, HasPermission: False
Permission: CreateSSCSite, HasPermission: False
Permission: ManageSubwebs, HasPermission: False
Permission: CreateGroups, HasPermission: False
Permission: ManagePermissions, HasPermission: False
Permission: BrowseDirectories, HasPermission: False
Permission: BrowseUserInfo, HasPermission: True
Permission: AddDelPrivateWebParts, HasPermission: False
Permission: UpdatePersonalWebParts, HasPermission: False
Permission: ManageWeb, HasPermission: False
Permission: AnonymousSearchAccessWebLists, HasPermission: False
Permission: UseClientIntegration, HasPermission: True
Permission: UseRemoteAPIs, HasPermission: True
Permission: ManageAlerts, HasPermission: False
Permission: CreateAlerts, HasPermission: False
Permission: EditMyUserInfo, HasPermission: False
Permission: EnumeratePermissions, HasPermission: False
Permission: FullMask, HasPermission: False

the first thing i’m noticing is that EmptyMask is True which tells me like stated in the Documentation PermissionKind enumeration

Has no permissions on the Web site.

That the user has no permissions on the Web site, but the user i’m trying with is the Site Collection Administrator. He is in the Administrators Group and Has Full Control Permission level.

Also permissions like AddListItems, Edit, Delete are all returning false, but the user has indeed the rights to do that.

Where am I doing wrong? Or does one of the permission tells me that he has all these rights ?

=================

=================

1 Answer
1

=================

I had the same problem as yours. I was passing username in format “domain\username” but it was returning all permissions as false. Finally I realized that I was using Claims based authentication for SharePoint. I changed username to claims format “i:0#.w|domain\username” and it started working perfectly after that. Hope this helps.