How to check if a user has permission to a SharePoint site collection -
what best way check if user has permission site collection/site? i'm using following
spsecurity.runwithelevatedprivileges( () => {using (var site = new spsite(nodeurl)) { using (var web = site.openweb()) { retvalue= web.doesuserhavepermissions( context.user.identity.name, spbasepermissions.open); } } });
this doesn't seem working properly. if user never added site works. if user added , removed doesuserhavepermission(.. spbasepermission.open)
still returns true, when user tries access site sharepoint throws access denied page.
after little more digging found user account still in web.allusers
list, has no roles assigned.
use checkpermissions
instead of doesuserhavepermissions
. see spweb.checkpermissions method .
Comments
Post a Comment