c# - Why is my List.GetUserEffectivePermissions() method not working? -
i'm developing process in c# sharepoint 2013 client side object model. need retrieve sharepoint list permissions of given user, different user executing code.
using sp = microsoft.sharepoint.client; sp.clientcontext spcontext = new sp.clientcontext("siteurl"); sp.web siteweb = spcontext.web; sp.list lst = spcontext.web.lists.getbytitle("list"); var clientusereffperms = lst.getusereffectivepermissions(@"<domain>\<username>"); spcontext.load(siteweb, s => s.effectivebasepermissions); spcontext.load(lst, l => l.effectivebasepermissions); spcontext.executequery();
after code executes, clientusereffperms.value (basepermissions) object not represent permissions of given user correctly. object isn't null, represents user having no permissions. user has @ minimum view , edit permissions , can confirm viewing/editing list items using web browser user.
the code executing user has permission enumerate permissions @ both web , list level. i've confirmed code below, both booleans resolve true.
bool svcuserhassiteenumpermsperm = siteweb.effectivebasepermissions.has(sp.permissionkind.enumeratepermissions); bool svcuserhaslistenumpermsperm = lst.effectivebasepermissions.has(sp.permissionkind.enumeratepermissions);
can me determine wrong getusereffectivepermissions() method?
when call getusereffectivepermissions need pass in full claims token version of login name, looks this:
i:0#.w|domain\user
you can loading loginname property on user object:
clientcontext.load(clientcontext.web.currentuser, => i.loginname); clientcontext.executequery();
of course, that's current user, you'll need acquire user want first.
Comments
Post a Comment