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(); }
protected override void PrepareRecipientAlias(ADUser dataObject) { if (!string.IsNullOrEmpty(base.Alias)) { dataObject.Alias = base.Alias; return; } if (string.IsNullOrEmpty(dataObject.Alias)) { dataObject.Alias = RecipientTaskHelper.GenerateUniqueAlias(base.TenantGlobalCatalogSession, dataObject.OrganizationId, string.IsNullOrEmpty(dataObject.UserPrincipalName) ? dataObject.SamAccountName : RecipientTaskHelper.GetLocalPartOfUserPrincalName(dataObject.UserPrincipalName), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } }