protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (this.FederatedIdentity != null && this.Password != null) { base.WriteError(new RecipientTaskException(Strings.ErrorFederatedIdentityandPasswordTogether), ExchangeErrorCategory.Client, this.DataObject.Identity); } if (this.DataObject.IsChanged(MailUserSchema.WindowsLiveID)) { MailboxTaskHelper.IsMemberExists((IRecipientSession)base.DataSession, this.DataObject.WindowsLiveID, new Task.ErrorLoggerDelegate(base.WriteError)); } if (this.DataObject.IsModified(MailUserSchema.UserPrincipalName)) { if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.ValidateExternalEmailAddressInAcceptedDomain.Enabled&& this.ShouldCheckAcceptedDomains()) { RecipientTaskHelper.ValidateInAcceptedDomain(this.ConfigurationSession, this.DataObject.OrganizationId, RecipientTaskHelper.GetDomainPartOfUserPrincalName(this.DataObject.UserPrincipalName), new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache); } RecipientTaskHelper.IsUserPrincipalNameUnique(base.TenantGlobalCatalogSession, this.DataObject, this.DataObject.UserPrincipalName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client); } if (this.DataObject.IsChanged(MailboxSchema.JournalArchiveAddress) && this.DataObject.JournalArchiveAddress != SmtpAddress.NullReversePath && this.DataObject.JournalArchiveAddress != SmtpAddress.Empty) { RecipientTaskHelper.IsJournalArchiveAddressUnique(base.TenantGlobalCatalogSession, this.DataObject.OrganizationId, this.DataObject, this.DataObject.JournalArchiveAddress, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client); } if (this.DataObject.IsModified(MailUserSchema.SamAccountName)) { RecipientTaskHelper.IsSamAccountNameUnique(this.DataObject, this.DataObject.SamAccountName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client); } TaskLogger.LogExit(); }
protected override void PrepareRecipientObject(ADUser user) { TaskLogger.LogEnter(); base.PrepareRecipientObject(user); user.RecipientTypeDetails = RecipientTypeDetails.LinkedUser; user.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.LinkedUser); if (this.LinkedMasterAccount != null) { user.MasterAccountSid = this.linkedUserSid; } RecipientTaskHelper.IsUserPrincipalNameUnique(base.TenantGlobalCatalogSession, user, user.UserPrincipalName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client); TaskLogger.LogExit(); }
internal static void ValidateUserParameters(ADUser userObject, IConfigurationSession configSession, IRecipientSession globalCatalogSession, Task.TaskVerboseLoggingDelegate verboseLogger, Task.ErrorLoggerDelegate errorLogger, ExchangeErrorCategory errorLoggerCategory, bool shouldCheckAcceptedDomains, ProvisioningCache provisioningCache) { if (userObject.IsModified(UserSchema.ResetPasswordOnNextLogon) && userObject.ResetPasswordOnNextLogon && (userObject.UserAccountControl & UserAccountControlFlags.DoNotExpirePassword) != UserAccountControlFlags.None) { errorLogger(new TaskInvalidOperationException(Strings.ErrorUserCannotChangePasswordAtNextLogon(userObject.Identity.ToString())), errorLoggerCategory, userObject.Identity); } if (userObject.IsModified(UserSchema.UserPrincipalName)) { if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.ValidateExternalEmailAddressInAcceptedDomain.Enabled&& shouldCheckAcceptedDomains) { RecipientTaskHelper.ValidateInAcceptedDomain(configSession, userObject.OrganizationId, RecipientTaskHelper.GetDomainPartOfUserPrincalName(userObject.UserPrincipalName), errorLogger, provisioningCache); } RecipientTaskHelper.IsUserPrincipalNameUnique(globalCatalogSession, userObject, userObject.UserPrincipalName, verboseLogger, errorLogger, errorLoggerCategory); } if (userObject.IsModified(UserSchema.SamAccountName)) { RecipientTaskHelper.IsSamAccountNameUnique(globalCatalogSession, userObject, userObject.SamAccountName, verboseLogger, errorLogger, errorLoggerCategory); } }
protected override void PrepareRecipientObject(ADUser user) { TaskLogger.LogEnter(); string userPrincipalName = user.UserPrincipalName; base.PrepareRecipientObject(user); bool flag = base.Fields.Contains("SoftDeletedObject"); if (flag && userPrincipalName != user.UserPrincipalName) { user.UserPrincipalName = userPrincipalName; } using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "NewUserBase.PrepareUserObject", LoggerHelper.CmdletPerfMonitors)) { this.PrepareUserObject(user); } if (!string.IsNullOrEmpty(this.ImmutableId)) { this.DataObject.ImmutableId = this.ImmutableId; } if (base.IsDebugOn) { base.WriteDebug(Strings.DebugStartUpnUniquenessCheck); } using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.IsUserPrincipalNameUnique", LoggerHelper.CmdletPerfMonitors)) { RecipientTaskHelper.IsUserPrincipalNameUnique(base.TenantGlobalCatalogSession, user, user.UserPrincipalName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.ServerOperation, !flag); } if (base.IsDebugOn) { base.WriteDebug(Strings.DebugEndUpnUniquenessCheck); } if (!string.IsNullOrEmpty(user.SamAccountName)) { using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.IsSamAccountNameUnique", LoggerHelper.CmdletPerfMonitors)) { RecipientTaskHelper.IsSamAccountNameUnique(base.TenantGlobalCatalogSession, user, user.SamAccountName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client, !flag); goto IL_2C1; } } bool useRandomSuffix = this.WindowsLiveID != null && this.WindowsLiveID.SmtpAddress != SmtpAddress.Empty; if (base.IsDebugOn) { base.WriteDebug(Strings.DebugStartGeneratingUniqueSamAccountName); } using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.PrepareRecipientObject/VariantConfiguration", LoggerHelper.CmdletPerfMonitors)) { IRecipientSession[] recipientSessions = new IRecipientSession[] { base.RootOrgGlobalCatalogSession }; if (VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.ServiceAccountForest.Enabled && base.CurrentOrganizationId != OrganizationId.ForestWideOrgId) { recipientSessions = new IRecipientSession[] { base.RootOrgGlobalCatalogSession, base.PartitionOrRootOrgGlobalCatalogSession }; } using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.GenerateUniqueSamAccountName", LoggerHelper.CmdletPerfMonitors)) { user.SamAccountName = RecipientTaskHelper.GenerateUniqueSamAccountName(recipientSessions, user.Id.DomainId, RecipientTaskHelper.GetLocalPartOfUserPrincalName(user.UserPrincipalName), false, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), useRandomSuffix); } } if (base.IsDebugOn) { base.WriteDebug(Strings.DebugEndGeneratingUniqueSamAccountName); } IL_2C1: if (string.IsNullOrEmpty(user.Alias)) { using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.GenerateUniqueAlias", LoggerHelper.CmdletPerfMonitors)) { user.Alias = RecipientTaskHelper.GenerateUniqueAlias(base.TenantGlobalCatalogSession, user.OrganizationId, string.IsNullOrEmpty(user.UserPrincipalName) ? user.SamAccountName : RecipientTaskHelper.GetLocalPartOfUserPrincalName(user.UserPrincipalName), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } } if (base.Fields.IsModified("SKUCapability")) { user.SKUCapability = new Capability?(this.SKUCapability); } if (base.Fields.IsModified("AddOnSKUCapability")) { CapabilityHelper.SetAddOnSKUCapabilities(this.AddOnSKUCapability, user.PersistedCapabilities); RecipientTaskHelper.UpgradeArchiveQuotaOnArchiveAddOnSKU(user, user.PersistedCapabilities); } if (base.Fields.IsModified(ADRecipientSchema.SKUAssigned)) { user.SKUAssigned = new bool?(this.SKUAssigned); } TaskLogger.LogExit(); }