public static void CreateSysadminPositions() { // first, verify there aren't actually any sysadmin positions. Defensive coding for the win. if (Positions.ForSystem().Count > 0) { throw new InvalidOperationException("Can't initialize sysadmin positions - already there"); } // Ok, so there are zero system-level positions. Create the Sysadmin positions. Position sysadminPrincipal = Position.Create(PositionLevel.SystemWide, null /* createdByPerson*/, null /*createdByPosition*/, PositionType.System_SysadminMain, PositionTitle.Default, false /*volunteerable*/, false /*overridable*/, null /*reportsTo*/, null /*dotReportsTo*/, 1 /*minCount*/, 1 /*maxCount*/); Position.Create(PositionLevel.SystemWide, null /* createdByPerson*/, null /*createdByPosition*/, PositionType.System_SysadminReadWrite, PositionTitle.Default, false, false, sysadminPrincipal, null /*dotReportsTo*/, 0 /*minCount*/, 0 /*maxCount*/); Position.Create(PositionLevel.SystemWide, null /* createdByPerson*/, null /*createdByPosition*/, PositionType.System_SysadminAssistantReadOnly, PositionTitle.Default, false, false, sysadminPrincipal, null /*dotReportsTo*/, 0 /*minCount*/, 0 /*maxCount*/); // If there's exactly one person in the system, we're undergoing Setup, so assign to Sysadmin Principal position. // Otherwise let grandfathering code handle it. People allPeople = People.GetAll(); // calling People.GetAll() would be a killer on well-built-out systems, but this code only runs once, and in Setup if (allPeople.Count == 1) { sysadminPrincipal.Assign(allPeople[0], null, null, "Assigned initial sysadmin", null); } }