We have code that does the following:

  1. Creates a new SPWeb programmatically within a site collection.
  2. Adds a new SPGroup to the programmatically-created SPWeb using spWeb.SiteGroups.Add(string name, SPMember owner, SPUser defaultUser, string description).

The invocation to add the SPGroup looks like this:

spWeb.SiteGroups.Add("Group Name", spWeb.Site.RootWeb.AssociatedOwnerGroup,
    spWeb.CurrentUser, "Group Description");

On all of our environments except for 1, this code works as expected. The owner of the new SPGroup is set to the AssociatedOwnerGroup of the site collection's root web.

However on one of our environments, spWeb.Site.RootWeb.AssociatedOwnerGroup is null, and thus the call to spWeb.SiteGroups.Add throws an ArgumentNullException for the owner argument.

We have checked, and the root site collection's Owners group is there.

What would cause spWeb.Site.RootWeb.AssociatedOwnerGroup to return null?


The spWeb.CurrentUser is a site collection administrator.

We have tried wrapping this in SPSecurity.RunWithElevatedPrivileges, but the result is the same.


Not sure why it could be empty - perhaps was deleted at some point (this has happened to me before). You can set the owner by visiting _layouts/permsetup.aspx of your site collection.

  • Yes, that did it. Never heard of this ASPX before, is there any way to get to it without typing in the URL? – danludwig Nov 5 '14 at 16:43
  • Great! I don't think there is a way to the page through the UI. The groups are also configurable through PowerShell. See this page – Kevin Stone Nov 5 '14 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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