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.