I created a SharePoint Hosted App and trying to get the current user's permission on their web.
Please refer to the below code snippet, I'm passing the siteurl as parameter to which I have full control access.
I'm in fact a site collection admin on this "siteurl" but when I check for its permissions it always returns 'false'. Is there a way do get the permissions of the current user on its web? Below is the snippet of the code
var ctx = new SP.ClientContext(appweburl); var factory = new SP.ProxyWebRequestExecutorFactory(appweburl); ctx.set_webRequestExecutorFactory(factory); var appContextSite = new SP.AppContextSite(ctx, siteurl); var web = appContextSite.get_web(); ctx.load(web, 'EffectiveBasePermissions'); ctx.executeQueryAsync( // OnSuccess function (sender, args) { var value = web.get_effectiveBasePermissions(); console.log(value); var hasPermission = web.get_effectiveBasePermissions().has(SP.PermissionKind.viewListItems); var text = "<li>" + siteurl + ": " + "<b>" + hasPermission + "</b></li>"; $('#message ul').append(text); }, // OnFailure function (sender, args) { console.log('request failed ' + args.get_message() + '\n' + args.get_stackTrace()); });
Vamsi Munagala