Skip to main content
Tweeted twitter.com/StackSharePoint/status/1300810671349731328
deleted 5 characters in body
Source Link
Robert Lindgren
  • 24.5k
  • 12
  • 53
  • 79

i'mI'm trying to get the property "IsSiteAdmin" from a user object in Javascript JSOM. The app I am programming needs to be able to distinguish from normal users orfrom Administrators.

function isUserHostWebAdmin() {

    var hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));

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

    var user = hostWebContext.get_web().get_currentUser();
    context.load(user);

    context.executeQueryAsync(onAppReadySuccess, null);


    function onAppReadySuccess() {
        alert(user.get_isSiteAdmin());
    }
}

the ProblemThe problem here is, that I always get "false" as a respond. The current user was always either the SharePoint Online AdmistratorAdministrator (for Office 365) or the Administrator for SharePoint OnpremisOn Premise.

Does anyone know why I had a working solutionhow to solve this issue?

btw. I also tried to get the user both from the host web context and the app web context.

i'm trying to get the property "IsSiteAdmin" from a user object in Javascript JSOM. The app I am programming needs to be able to distinguish from normal users or Administrators.

function isUserHostWebAdmin() {

    var hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));

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

    var user = hostWebContext.get_web().get_currentUser();
    context.load(user);

    context.executeQueryAsync(onAppReadySuccess, null);


    function onAppReadySuccess() {
        alert(user.get_isSiteAdmin());
    }
}

the Problem here is, that I always get "false" as a respond. The current user was always either the SharePoint Online Admistrator (for Office 365) or the Administrator for SharePoint Onpremis.

Does anyone know why I had a working solution?

btw. I also tried to get the user from the host web context and the app web context.

I'm trying to get the property "IsSiteAdmin" from a user object in Javascript JSOM. The app I am programming needs to be able to distinguish normal users from Administrators.

function isUserHostWebAdmin() {

    var hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));

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

    var user = hostWebContext.get_web().get_currentUser();
    context.load(user);

    context.executeQueryAsync(onAppReadySuccess, null);


    function onAppReadySuccess() {
        alert(user.get_isSiteAdmin());
    }
}

The problem here is that I always get "false" as a respond. The current user was always either the SharePoint Online Administrator (for Office 365) or the Administrator for SharePoint On Premise.

Does anyone know how to solve this issue?

btw. I tried to get the user both from the host web context and the app web context.

deleted 241 characters in body
Source Link

i'm trying to get the property "IsSiteAdmin" from a user object in Javascript JSOM. The app I am programming needs to be able to distinguish from normal users or Administrators.

function isUserHostWebAdmin() {

    // http://styledpoint.com/blog/sharepoint-2010-check-to-see-if-user-exists-in-a-group-via-javascript-ecma/
    // http://msdn.microsoft.com/en-us/library/office/hh185014(v=office.14).aspx
    var hostweburl = decodeURIComponent(FuM.Helper.Querystring.getQueryStringParameter('SPHostUrl'));
    var appweburl = decodeURIComponent(FuM.Helper.Querystring.getQueryStringParameter('SPAppWebUrl'));

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

    var user = hostWebContext.get_web().get_currentUser();
    context.load(user);

    context.executeQueryAsync(onAppReadySuccess, null);


    function onAppReadySuccess() {
        alert(user.get_isSiteAdmin());
    }
}

the Problem here is, that I always get "false" as a respond. The current user was always either the SharePoint Online Admistrator (for Office 365) or the Administrator for SharePoint Onpremis.

Does anyone know why I had a working solution?

btw. I also tried to get the user from the host web context and the app web context.

i'm trying to get the property "IsSiteAdmin" from a user object in Javascript JSOM. The app I am programming needs to be able to distinguish from normal users or Administrators.

function isUserHostWebAdmin() {

    // http://styledpoint.com/blog/sharepoint-2010-check-to-see-if-user-exists-in-a-group-via-javascript-ecma/
    // http://msdn.microsoft.com/en-us/library/office/hh185014(v=office.14).aspx
    var hostweburl = decodeURIComponent(FuM.Helper.Querystring.getQueryStringParameter('SPHostUrl'));
    var appweburl = decodeURIComponent(FuM.Helper.Querystring.getQueryStringParameter('SPAppWebUrl'));

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

    var user = hostWebContext.get_web().get_currentUser();
    context.load(user);

    context.executeQueryAsync(onAppReadySuccess, null);


    function onAppReadySuccess() {
        alert(user.get_isSiteAdmin());
    }
}

the Problem here is, that I always get "false" as a respond. The current user was always either the SharePoint Online Admistrator (for Office 365) or the Administrator for SharePoint Onpremis.

Does anyone know why I had a working solution?

btw. I also tried to get the user from the host web context and the app web context.

i'm trying to get the property "IsSiteAdmin" from a user object in Javascript JSOM. The app I am programming needs to be able to distinguish from normal users or Administrators.

function isUserHostWebAdmin() {

    var hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));

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

    var user = hostWebContext.get_web().get_currentUser();
    context.load(user);

    context.executeQueryAsync(onAppReadySuccess, null);


    function onAppReadySuccess() {
        alert(user.get_isSiteAdmin());
    }
}

the Problem here is, that I always get "false" as a respond. The current user was always either the SharePoint Online Admistrator (for Office 365) or the Administrator for SharePoint Onpremis.

Does anyone know why I had a working solution?

btw. I also tried to get the user from the host web context and the app web context.

Source Link

JSOM function get_isSiteAdmin() is always false

i'm trying to get the property "IsSiteAdmin" from a user object in Javascript JSOM. The app I am programming needs to be able to distinguish from normal users or Administrators.

function isUserHostWebAdmin() {

    // http://styledpoint.com/blog/sharepoint-2010-check-to-see-if-user-exists-in-a-group-via-javascript-ecma/
    // http://msdn.microsoft.com/en-us/library/office/hh185014(v=office.14).aspx
    var hostweburl = decodeURIComponent(FuM.Helper.Querystring.getQueryStringParameter('SPHostUrl'));
    var appweburl = decodeURIComponent(FuM.Helper.Querystring.getQueryStringParameter('SPAppWebUrl'));

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

    var user = hostWebContext.get_web().get_currentUser();
    context.load(user);

    context.executeQueryAsync(onAppReadySuccess, null);


    function onAppReadySuccess() {
        alert(user.get_isSiteAdmin());
    }
}

the Problem here is, that I always get "false" as a respond. The current user was always either the SharePoint Online Admistrator (for Office 365) or the Administrator for SharePoint Onpremis.

Does anyone know why I had a working solution?

btw. I also tried to get the user from the host web context and the app web context.