1

I'm trying to add an account to the site collection owners on users personal sites. I'm using the following:

User spUser = null;
using (ClientContext clientContext = new ClientContext(siteURL)) {
    clientContext.Credentials = credentials;
    if (clientContext != null)
    {
        spUser = clientContext.Web.EnsureUser(userAccount);
        spUser.IsSiteAdmin = true;
        spUser.Update();

        clientContext.Load(spUser);
        clientContext.ExecuteQuery();
    }
}

but I'm getting this error:

You need to be a site collection administrator to set this property.

On the Sharepoint site, the user is under site collection Administrators.

I'm also looking to do this from a console application.

1 Answer 1

1

The error You need to be a site collection administrator to set this property occurs when one of the following conditions does not met:

  • Ensure the user performing a request is a Site Collection Administrator
  • Ensure permissions for the App, explicitly request FullControl permission at the Site Collection scope as shown below:

enter image description here

Follow Adding Site Collection Admin in CSOM in a SharePoint 2013 App article for a more details.

1
  • I'm using a console app to apply the permissions and trying to apply to sharepoint online. I'm hoping to then use this code in powershell
    – Webfort
    Commented Dec 13, 2014 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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