I do have a client context ClientContext context and current user:

var currentUser = context.Web.CurrentUser;



I can also use rest API.


Solved this using Graph API rest request:


Documentation: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations


I use this for SharePoint Online:

_clientContext.Load(_clientContext.Site, s => s.Url);
var tenantUrl = $"https://{new Uri(_clientContext.Url).Host.Replace(".sharepoint.com", "-admin.sharepoint.com")}";
var tenantCtx = new ClientContext(tenantUrl);
tenantCtx.Credentials = _clientContext.Credentials;
var tenant = new Tenant(tenantCtx);
var props = tenant.GetSitePropertiesByUrl(_clientContext.Site.Url, false);
tenant.Context.ExecuteQuery(); // will throw 401 exception here, if current user is not tenant admin

Try this:

if (clientcontext.Web.CurrentUser.IsSiteAdmin) 
   Your Code
  • this returns if a user is a site admin. user can be or not be a site admin when he is a global admin. Mar 15 '16 at 8:24
  • I am not sure about how to do it with CSOM but why not try with PowerShell? You will get the list of users who are Global Admins office365support.ca/…
    – Zakir HC
    Mar 15 '16 at 8:59
  • I'm developing an application where Global Admin has admin features so i need to check this in runtime. Mar 15 '16 at 9:04
  • sometimes this code Web.CurrentUser.IsSiteAdmin fails in onpremises.i have tested multiple times within a visual web part, event receivers for checking a user is belonging to siteadmin or not. but it returns incorrect data. Mar 15 '16 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.