This project is read-only.

Scenario add site collection administrators on OneDrive

Jun 18, 2014 at 8:21 AM
When looking at the Core.Site.Permissions scenario it states that you already have to be site collection administrator to add additional site collection admins. We are however looking at a scenario where we want to automatically add a specific admin account on every created OneDrive. Is this a scenario which is going to be added to Office AMS?


Joris []
Jun 18, 2014 at 10:15 AM
Hi Joris,
Tenant object exposes SetSiteAdmin method for this. Following is from the core component implemenentation (SecurityExtensions) as a reference. This one adds user as the site collection administrator and also includes that to the onwers group.
    public static void AddAdministratorsTenant(this Web web, String[] adminLogins, Uri siteUrl)
        Tenant tenant = new Tenant(web.Context);

        foreach (var admin in adminLogins)
            tenant.SetSiteAdmin(siteUrl.ToString(), admin, true);
            var spAdmin = web.EnsureUser(admin);
Jun 19, 2014 at 12:47 AM
Edited Jun 19, 2014 at 12:47 AM
I've just tried doing this to giving the global administrator site administrator access to all personal sites, and it works fine, but I'm not sure I understand your code sample - why would you need to add each user to the AssociatedOwnerGroup, and why would you do ExecuteQuery() inside the loop?
Jun 23, 2014 at 1:10 PM
there's really no reason for the AsssociatedOwnerGroup change, but just pasted the code from the Core component method as it is.