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.