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

Traditionally I use:

if (web.CurrentUser.Name == "System Account")

Is there a possibility the System Account Name could be something other then "System Account". Is there a more reliable way to check if CurrentUser is the System Account?

This is using SharePoint 2010.

share|improve this question
add comment

3 Answers 3

up vote 7 down vote accepted

To check if the Current User is system account you can use

if (web.CurrentUser.ID == web.Site.SystemAccount.ID) 

SystemAccount is a property of SPSite object which gets the System Account of the site collection

share|improve this answer
add comment
SPContext.Current.Web.CurrentUser.ID == SPContext.Current.Site.SystemAccount.ID

This method is suitable?

share|improve this answer
    
Yes except SPContext is null for me this in this case so I had to go with the SPWeb object from the event properties to grab the CurrenUser –  Meyer Denney Aug 9 '12 at 5:37
add comment

Yes actually you can.

  • Go to central administration

    1. Click on Security on the left
    2. Click on "Specify web application user policy"
    3. Click on the account you want to check on
    4. Check or uncheck the "Choose System Settings" option with "Account Operates as System"
share|improve this answer
    
-1 Unfortunately you appear to be answering the wrong question –  Stuart Pegg Aug 9 '12 at 8:19
add comment

Your Answer

 
discard

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

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