While trying to find out a better way to check if current user operates as System Account, other then checking if the login name is “
SHAREPOINT/system” string, I’ve stumbled upon
SPSite.SystemAccount property.
So the problem is cut down to:
- in event handlers
- web.Site.SystemAccount.ID == properties.CurrentUserId
- in web pages or controls
- SPContext.Current.Web.CurrentUser.ID == SPContext.Current.Site.SystemAccount.ID
You can change
SPContext.Current.Web with your
SPWeb instance variable. Same goes for
SPContext.Current.Site.
No comments:
Post a Comment