protected override void InternalProcessRecord() { base.InternalProcessRecord(); QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, PublicFolderTreeSchema.PublicFolderTreeType, PublicFolderTreeType.Mapi); PublicFolderTree[] array = ((IConfigurationSession)base.DataSession).Find <PublicFolderTree>(null, QueryScope.SubTree, filter, null, 0); if (array == null || array.Length == 0) { PublicFolderTreeContainer publicFolderTreeContainer = this.InstallConfigurationObject <PublicFolderTreeContainer>(this.DataObject.Id.GetChildId(PublicFolderTreeContainer.DefaultName), false); this.InstallConfigurationObject <PublicFolderTree>(publicFolderTreeContainer.Id.GetChildId(PublicFolderTree.DefaultName), true); } this.InstallConfigurationObject <ServersContainer>(this.DataObject.Id.GetChildId(ServersContainer.DefaultName), false); this.InstallConfigurationObject <Container>(ClientAccessArray.GetParentContainer((ITopologyConfigurationSession)base.DataSession), false); this.InstallConfigurationObject <DatabasesContainer>(this.DataObject.Id.GetChildId(DatabasesContainer.DefaultName), false); this.InstallConfigurationObject <DatabaseAvailabilityGroupContainer>(this.DataObject.Id.GetChildId(DatabaseAvailabilityGroupContainer.DefaultName), false); AdvancedSecurityContainer advancedSecurityContainer = this.InstallConfigurationObject <AdvancedSecurityContainer>(this.DataObject.Id.GetChildId("Advanced Security"), false); Encryption encryption = new Encryption(); encryption[EncryptionSchema.LegacyExchangeDN] = string.Format("{0}/cn=Configuration/cn={1}", this.DataObject.LegacyExchangeDN, Encryption.DefaultName); this.InstallConfigurationObject <Encryption>(advancedSecurityContainer.Id.GetChildId(Encryption.DefaultName), false, encryption); this.InstallConfigurationObject <LegacyGwart>(this.DataObject.Id.GetChildId(LegacyGwart.DefaultName), false); this.InstallConfigurationObject <RoutingGroupsContainer>(this.DataObject.Id.GetChildId(RoutingGroupsContainer.DefaultName), false); this.InstallConfigurationObject <RoutingGroup>(this.DataObject.Id.GetChildId(RoutingGroupsContainer.DefaultName).GetChildId(RoutingGroup.DefaultName), false); this.InstallConfigurationObject <ConnectorsContainer>(this.DataObject.Id.GetChildId(RoutingGroupsContainer.DefaultName).GetChildId(RoutingGroup.DefaultName).GetChildId("Connections"), false); }
public void CreatePublicFolderTree() { this.pfTree = new PublicFolderTree(); try { QueryFilter filter; ADObjectId adobjectId; if (Datacenter.GetExchangeSku() != Datacenter.ExchangeSku.ExchangeDatacenter) { filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, PublicFolderTreeContainer.DefaultName); PublicFolderTreeContainer[] array = this.taskInstance.GlobalConfigSession.Find <PublicFolderTreeContainer>(null, QueryScope.SubTree, filter, null, 1); PublicFolderTreeContainer publicFolderTreeContainer; if (array == null || array.Length == 0) { filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, AdministrativeGroup.DefaultName); AdministrativeGroup[] array2 = this.taskInstance.GlobalConfigSession.Find <AdministrativeGroup>(null, QueryScope.SubTree, filter, null, 1); if (array2 == null || array2.Length < 1) { throw new AdminGroupNotFoundException(AdministrativeGroup.DefaultName); } publicFolderTreeContainer = new PublicFolderTreeContainer(); publicFolderTreeContainer.SetId(array2[0].Id.GetChildId(PublicFolderTreeContainer.DefaultName)); this.taskInstance.DataSession.Save(publicFolderTreeContainer); } else { publicFolderTreeContainer = array[0]; } adobjectId = publicFolderTreeContainer.Id; } else { adobjectId = this.OrganizationId.ConfigurationUnit; this.pfTree.OrganizationId = this.OrganizationId; } this.pfTree.SetId(adobjectId.GetChildId("Public Folders")); this.taskInstance.WriteVerbose(Strings.VerboseCreatePublicFolderTree(this.pfTree.Id.ToString())); this.pfTree.PublicFolderTreeType = PublicFolderTreeType.Mapi; filter = new ComparisonFilter(ComparisonOperator.Equal, ExtendedRightSchema.DisplayName, "Create public folder"); this.taskInstance.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(this.taskInstance.GlobalConfigSession, typeof(ExtendedRight), filter, this.taskInstance.GlobalConfigSession.ConfigurationNamingContext, true)); ExtendedRight[] array3 = this.taskInstance.GlobalConfigSession.Find <ExtendedRight>(this.taskInstance.GlobalConfigSession.ConfigurationNamingContext, QueryScope.SubTree, filter, null, 1); if (0 < array3.Length) { ObjectAce objectAce = new ObjectAce(AceFlags.None, AceQualifier.AccessAllowed, 256, new SecurityIdentifier("AU"), ObjectAceFlags.ObjectAceTypePresent, array3[0].RightsGuid, Guid.Empty, false, null); DiscretionaryAcl discretionaryAcl = new DiscretionaryAcl(false, true, 11); discretionaryAcl.AddAccess(AccessControlType.Allow, objectAce.SecurityIdentifier, objectAce.AccessMask, objectAce.InheritanceFlags, objectAce.PropagationFlags, objectAce.ObjectAceFlags, objectAce.ObjectAceType, objectAce.InheritedObjectAceType); using (WindowsIdentity current = WindowsIdentity.GetCurrent()) { SecurityIdentifier user = current.User; CommonSecurityDescriptor commonSecurityDescriptor = new CommonSecurityDescriptor(false, true, ControlFlags.DiscretionaryAclPresent, user, user, null, discretionaryAcl); byte[] binaryForm = new byte[commonSecurityDescriptor.BinaryLength]; commonSecurityDescriptor.GetBinaryForm(binaryForm, 0); this.pfTree.SetPublicFolderDefaultAdminAcl(new RawSecurityDescriptor(binaryForm, 0)); } } this.taskInstance.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.TenantSession)); this.taskInstance.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(this.pfTree, this.TenantSession, typeof(PublicFolderTree))); this.TenantSession.Save(this.pfTree); if (Datacenter.GetExchangeSku() == Datacenter.ExchangeSku.ExchangeDatacenter) { this.SetOrganizationManagementACLs(this.pfTree); } } finally { this.taskInstance.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.TenantSession)); } }