protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (base.HasErrors) { return; } ExchangeOrganizationalUnit exchangeOrganizationalUnit = null; if (base.Fields.IsModified("DefaultDistributionListOU")) { this.DataObject.DefaultDistributionListOU = ((this.defaultOU == null) ? null : this.defaultOU.Id); exchangeOrganizationalUnit = this.defaultOU; } else if (this.DataObject.IsChanged(RecipientTemplateProvisioningPolicySchema.DefaultDistributionListOU) && this.DataObject.DefaultDistributionListOU != null) { exchangeOrganizationalUnit = RecipientTaskHelper.ResolveOrganizationalUnitInOrganization(new OrganizationalUnitIdParameter(this.DataObject.DefaultDistributionListOU), this.ConfigurationSession, null, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), ExchangeErrorCategory.Client, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); } if (exchangeOrganizationalUnit != null) { OrganizationId organizationId = OrganizationId.ForestWideOrgId; if (this.ConfigurationSession is ITenantConfigurationSession) { organizationId = TaskHelper.ResolveOrganizationId(this.DataObject.Id, ADProvisioningPolicy.RdnContainer, (ITenantConfigurationSession)this.ConfigurationSession); } RecipientTaskHelper.IsOrgnizationalUnitInOrganization(this.ConfigurationSession, organizationId, exchangeOrganizationalUnit, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); } TaskLogger.LogExit(); }
protected override void PrepareRecipientObject(ADDynamicGroup group) { TaskLogger.LogEnter(); base.PrepareRecipientObject(group); if (base.OrganizationalUnit == null && group[ADRecipientSchema.DefaultDistributionListOU] != null) { ADObjectId adobjectId = (ADObjectId)group[ADRecipientSchema.DefaultDistributionListOU]; RecipientTaskHelper.ResolveOrganizationalUnitInOrganization(new OrganizationalUnitIdParameter(adobjectId), this.ConfigurationSession, base.CurrentOrganizationId, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), ExchangeErrorCategory.ServerOperation, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); group.SetId(adobjectId.GetChildId(base.Name)); } if (this.RecipientContainer == null) { if (!base.Fields.IsModified(ADDynamicGroupSchema.RecipientContainer)) { group.RecipientContainer = group.Id.Parent; } } else { bool useConfigNC = this.ConfigurationSession.UseConfigNC; bool useGlobalCatalog = this.ConfigurationSession.UseGlobalCatalog; this.ConfigurationSession.UseConfigNC = false; if (string.IsNullOrEmpty(this.ConfigurationSession.DomainController)) { this.ConfigurationSession.UseGlobalCatalog = true; } ExchangeOrganizationalUnit exchangeOrganizationalUnit = (ExchangeOrganizationalUnit)base.GetDataObject <ExchangeOrganizationalUnit>(this.RecipientContainer, this.ConfigurationSession, (base.CurrentOrganizationId != null) ? base.CurrentOrganizationId.OrganizationalUnit : null, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(this.RecipientContainer.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(this.RecipientContainer.ToString())), ExchangeErrorCategory.Client); RecipientTaskHelper.IsOrgnizationalUnitInOrganization(this.ConfigurationSession, group.OrganizationId, exchangeOrganizationalUnit, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); this.ConfigurationSession.UseConfigNC = useConfigNC; this.ConfigurationSession.UseGlobalCatalog = useGlobalCatalog; group.RecipientContainer = (ADObjectId)exchangeOrganizationalUnit.Identity; } group.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.DynamicDistributionGroup); TaskLogger.LogExit(); }
protected override void ResolveLocalSecondaryIdentities() { base.ResolveLocalSecondaryIdentities(); if (this.DefaultDistributionListOU != null) { this.defaultOU = RecipientTaskHelper.ResolveOrganizationalUnitInOrganization(this.DefaultDistributionListOU, this.ConfigurationSession, null, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), ExchangeErrorCategory.Client, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.ThrowTerminatingError)); } }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (base.HasErrors) { return; } if (this.DataObject.DefaultDistributionListOU != null) { RecipientTaskHelper.ResolveOrganizationalUnitInOrganization(new OrganizationalUnitIdParameter(this.DataObject.DefaultDistributionListOU), (IConfigurationSession)base.DataSession, (base.CurrentOrganizationId != null) ? base.CurrentOrganizationId : OrganizationId.ForestWideOrgId, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), ExchangeErrorCategory.Client, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); } TaskLogger.LogExit(); }
protected override void PrepareRecipientObject(ADGroup group) { TaskLogger.LogEnter(); base.PrepareRecipientObject(group); Organization organization; if (base.Organization == null) { organization = this.ConfigurationSession.GetOrgContainer(); } else { organization = this.ConfigurationSession.Read <ExchangeConfigurationUnit>(base.CurrentOrgContainerId); } ADObjectId adobjectId = null; base.TryGetExecutingUserId(out adobjectId); if (!this.IgnoreNamingPolicy.IsPresent && adobjectId != null) { ADUser user = (ADUser)RecipientTaskHelper.CreatePartitionOrRootOrgScopedGcSession(null, adobjectId).Read(adobjectId); string groupNameWithNamingPolicy = DistributionGroupTaskHelper.GetGroupNameWithNamingPolicy(organization, user, group, base.Name, ADObjectSchema.Name, new Task.ErrorLoggerDelegate(base.WriteError)); if (groupNameWithNamingPolicy.Length > 64) { base.WriteError(new RecipientTaskException(Strings.ErrorDistributionGroupNameTooLong), ExchangeErrorCategory.Client, null); } base.Name = groupNameWithNamingPolicy; if (!string.IsNullOrEmpty(base.DisplayName)) { base.DisplayName = DistributionGroupTaskHelper.GetGroupNameWithNamingPolicy(organization, user, group, base.DisplayName, ADRecipientSchema.DisplayName, new Task.ErrorLoggerDelegate(base.WriteError)); } } if (base.OrganizationalUnit == null && !ADObjectId.IsNullOrEmpty(organization.DistributionGroupDefaultOU)) { group.SetId(organization.DistributionGroupDefaultOU.GetChildId(base.Name)); } if (base.OrganizationalUnit == null && group[ADRecipientSchema.DefaultDistributionListOU] != null) { ADObjectId adobjectId2 = (ADObjectId)group[ADRecipientSchema.DefaultDistributionListOU]; RecipientTaskHelper.ResolveOrganizationalUnitInOrganization(new OrganizationalUnitIdParameter(adobjectId2), this.ConfigurationSession, base.CurrentOrganizationId, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), ExchangeErrorCategory.Client, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); group.SetId(adobjectId2.GetChildId(base.Name)); } if (this.Type != GroupType.Distribution && this.Type != GroupType.Security) { base.WriteError(new RecipientTaskException(Strings.ErrorGroupTypeInvalid), ExchangeErrorCategory.Client, null); } if (base.Fields.IsModified(DistributionGroupSchema.ManagedBy)) { MailboxTaskHelper.StampOnManagedBy(this.DataObject, this.managedByRecipients, new Task.ErrorLoggerDelegate(base.WriteError)); } if (this.RoomList.IsPresent) { if (this.Type != GroupType.Distribution) { base.WriteError(new RecipientTaskException(Strings.ErrorCreateRoomListSecurityGroup(base.Name)), ExchangeErrorCategory.Client, base.Name); } group.RecipientTypeDetails = RecipientTypeDetails.RoomList; if (group.ManagedBy != null) { group.AcceptMessagesOnlyFromSendersOrMembers = new MultiValuedProperty <ADObjectId>(group.ManagedBy); } } MailboxTaskHelper.ValidateGroupManagedBy(base.TenantGlobalCatalogSession, group, this.managedByRecipients, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>), new Task.ErrorLoggerDelegate(base.WriteError)); MailboxTaskHelper.ValidateGroupManagedByRecipientRestriction(base.TenantGlobalCatalogSession, group, this.managedByRecipients, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); group.GroupType = (GroupTypeFlags)((GroupType)8 | this.Type); if (!group.IsChanged(ADRecipientSchema.RecipientDisplayType)) { if ((group.GroupType & GroupTypeFlags.SecurityEnabled) == GroupTypeFlags.SecurityEnabled) { group.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.SecurityDistributionGroup); } else { group.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.DistributionGroup); } } if (string.IsNullOrEmpty(group.SamAccountName)) { IRecipientSession[] recipientSessions = new IRecipientSession[] { base.RootOrgGlobalCatalogSession }; if (VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.ServiceAccountForest.Enabled && base.CurrentOrganizationId != OrganizationId.ForestWideOrgId) { recipientSessions = new IRecipientSession[] { base.RootOrgGlobalCatalogSession, base.PartitionOrRootOrgGlobalCatalogSession }; } group.SamAccountName = RecipientTaskHelper.GenerateUniqueSamAccountName(recipientSessions, group.Id.DomainId, group.Name, true, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), false); } else { RecipientTaskHelper.IsSamAccountNameUnique(group, group.SamAccountName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client); } if (string.IsNullOrEmpty(group.Alias)) { group.Alias = RecipientTaskHelper.GenerateUniqueAlias(base.TenantGlobalCatalogSession, base.CurrentOrganizationId, group.SamAccountName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } if (base.Fields.IsChanged(ADGroupSchema.Members) && this.Members != null) { foreach (RecipientIdParameter member in this.Members) { MailboxTaskHelper.ValidateAndAddMember(base.TenantGlobalCatalogSession, group, member, false, new Task.ErrorLoggerDelegate(base.WriteError), new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>)); } } if (this.CopyOwnerToMember.IsPresent && this.managedByRecipients != null) { foreach (ADRecipient adrecipient in this.managedByRecipients) { if (!group.Members.Contains(adrecipient.Id)) { MailboxTaskHelper.ValidateMemberInGroup(adrecipient, group, new Task.ErrorLoggerDelegate(base.WriteError)); group.Members.Add(adrecipient.Id); } } } if ((group.GroupType & GroupTypeFlags.Universal) == GroupTypeFlags.Universal) { MailboxTaskHelper.ValidateAddedMembers(base.TenantGlobalCatalogSession, group, new Task.ErrorLoggerDelegate(base.WriteError), new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>)); } if (!this.DataObject.IsModified(ADGroupSchema.MemberDepartRestriction)) { this.DataObject.MemberDepartRestriction = ((this.Type == GroupType.Security) ? MemberUpdateType.Closed : MemberUpdateType.Open); } if (group.ArbitrationMailbox == null) { group.ArbitrationMailbox = MailboxTaskHelper.GetArbitrationMailbox(base.TenantGlobalCatalogSession, base.CurrentOrgContainerId); if (group.ArbitrationMailbox == null) { if (group.MemberJoinRestriction == MemberUpdateType.ApprovalRequired || group.MemberDepartRestriction == MemberUpdateType.ApprovalRequired) { base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMbxNotSetForApproval(base.Name)), ExchangeErrorCategory.Client, group.Identity); } if (group.ModerationEnabled) { base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMbxNotSetForModeration(base.Name)), ExchangeErrorCategory.Client, group.Identity); } } } DistributionGroupTaskHelper.CheckMembershipRestriction(group, new Task.ErrorLoggerDelegate(base.WriteError)); TaskLogger.LogExit(); }