Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have tried following solution to check the current user's permissions on the current host web in a SharePoint hosted app, however the user is always administrator.

function sharePointReady() {
     hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
     appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));

     context = new SP.ClientContext.get_current();
      hostWebContext = new SP.AppContextSite(context, hostweburl);

     currentWeb = hostWebContext.get_web();
     user = hostWebContext.get_web().get_currentUser();
     context.load(user);
     context.load(currentWeb, 'EffectiveBasePermissions');

      context.executeQueryAsync(onAppReadySuccess, onAppReadyFailed);
}

function onAppReadySuccess() {

     alert(currentWeb.get_effectiveBasePermissions().has(SP.PermissionKind.fullMask));
}
share|improve this question
    
Can you provide some additional details? What permissions does the user actually have? Even if the user does not have permissions he is shown having the full mask permissions? –  Vardhaman Deshpande Mar 7 '13 at 5:23
    
Now when I have tested and logged in to my dev machine as Another user the code returned right person. the problem is when you use /_layouts/closeConnection.aspx?loginasanotheruser=true to log in as Another user then the user is Always that user that has loged on into the machine –  Medes Mar 7 '13 at 13:56
    
That's probably because you have to close the current browser session and open a new one before you login as another user. –  Vardhaman Deshpande Mar 7 '13 at 14:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.