REST API:
Use the below rest api to determine the current loggin user is site collection admin or not
https://<sharepointsiteurl>/_api/web/currentUser/issiteadmin
This returns the true
or false
value in xml format.
JS Format:
Use the below SharePoint ecmaScript to identify the current user admin status,
function checkUserisSiteAdmin() {
var clientContext = new SP.ClientContext();
oUser = clientContext.get_web().get_currentUser();
clientContext.load(oUser);
clientContext.executeQueryAsync(
Function.createDelegate(this, function() {
var userInfo = '';
userInfo +='LoginName: '+ oUser.get_loginName() +', SiteAdmin: '+ oUser.get_isSiteAdmin();
alert(userInfo.toString());
}),
Function.createDelegate(this, function(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}));
}
ExecuteOrDelayUntilScriptLoaded(checkUserisSiteAdmin, "sp.js");