SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

You can add users to the site collection administrators group through
Site Actions ->Site Collection Administrators (and add users)

But how can you do this through code? What is the grpName?

web.SiteGroups[grpName].AddUser(@User.LoginName, string.Empty, LookupValue, string.Empty);

share|improve this question
up vote 3 down vote accepted

You need to get the SPUser object for a user in a Site Collection and update the IsSiteAdmin property.

function makeUserSiteCollectionAdmin(SPUser user)
    user.IsSiteAdmin = true;
share|improve this answer
Worth noting that the account running the code (i.e. if in a webpart) needs permissions to make this change so a SPSecurity.RunWithElevatedPrivileges block might be required. – Neil Richards Feb 4 '11 at 12:00

Your Answer


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.