protected override void PrepareUserObject(ADUser user) { TaskLogger.LogEnter(); if (base.WindowsLiveID == null && base.SoftDeletedObject == null && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.WindowsLiveID.Enabled&& !RecipientTaskHelper.SMTPAddressCheckWithAcceptedDomain(this.ConfigurationSession, user.OrganizationId, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache)) { base.WriteError(new RecipientTaskException(Strings.ErrorWindowsLiveIdRequired(user.Name)), ExchangeErrorCategory.Client, null); } if (base.WindowsLiveID != null && base.WindowsLiveID.SmtpAddress != SmtpAddress.Empty) { if (this.ExternalEmailAddress == null) { user.ExternalEmailAddress = ProxyAddress.Parse(base.WindowsLiveID.SmtpAddress.ToString()); } user.UserPrincipalName = base.WindowsLiveID.SmtpAddress.ToString(); base.IsSetRandomPassword = (base.SoftDeletedObject == null || base.IsSetRandomPassword); } if (string.IsNullOrEmpty(user.UserPrincipalName)) { user.UserPrincipalName = RecipientTaskHelper.GenerateUniqueUserPrincipalName(base.TenantGlobalCatalogSession, user.Name, this.ConfigurationSession.GetDefaultAcceptedDomain().DomainName.Domain, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } if (base.SoftDeletedObject == null) { if (base.Fields.IsModified(MailUserSchema.RemotePowerShellEnabled)) { user.RemotePowerShellEnabled = this.RemotePowerShellEnabled; } else { user.RemotePowerShellEnabled = true; } MailUserTaskHelper.ValidateExternalEmailAddress(user, this.ConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache); } if (base.Fields.IsChanged(ADRecipientSchema.MailboxProvisioningConstraint)) { user.MailboxProvisioningConstraint = this.MailboxProvisioningConstraint; } if (base.Fields.IsChanged(ADRecipientSchema.MailboxProvisioningPreferences)) { user.MailboxProvisioningPreferences = this.MailboxProvisioningPreferences; } if (user.MailboxProvisioningConstraint != null) { MailboxTaskHelper.ValidateMailboxProvisioningConstraintEntries(new MailboxProvisioningConstraint[] { user.MailboxProvisioningConstraint }, base.DomainController, delegate(string message) { base.WriteVerbose(new LocalizedString(message)); }, new Task.ErrorLoggerDelegate(base.WriteError)); } if (user.MailboxProvisioningPreferences != null) { MailboxTaskHelper.ValidateMailboxProvisioningConstraintEntries(user.MailboxProvisioningPreferences, base.DomainController, delegate(string message) { base.WriteVerbose(new LocalizedString(message)); }, new Task.ErrorLoggerDelegate(base.WriteError)); } base.PrepareUserObject(user); TaskLogger.LogExit(); }
internal static ADUser SplitArchiveFromPrimary(ADUser primaryUser, IRecipientSession recipientSession = null) { ADUser aduser = null; if (!primaryUser.ArchiveGuid.Equals(Guid.Empty)) { aduser = new ADUser(); aduser.StampPersistableDefaultValues(); aduser.StampDefaultValues(RecipientType.UserMailbox); aduser.ResetChangeTracking(); AuxMailboxTaskHelper.AuxMailboxStampDefaultValues(aduser); aduser.AddressListMembership = primaryUser.AddressListMembership; aduser.DisplayName = string.Format("{0} {1}", Strings.ArchiveNamePrefix, primaryUser.DisplayName); aduser.OrganizationId = primaryUser.OrganizationId; aduser.ExchangeGuid = primaryUser.ArchiveGuid; aduser.Database = primaryUser.ArchiveDatabase; aduser.Alias = RecipientTaskHelper.GenerateAlias(string.Format("{0}{1}", Strings.ArchiveNamePrefix, aduser.ExchangeGuid)); aduser.Name = string.Format("{0}{1}", Strings.ArchiveNamePrefix, primaryUser.ExchangeGuid); if (recipientSession == null) { recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(primaryUser.OrganizationId), 74, "SplitArchiveFromPrimary", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Common\\recipient\\AuxMailboxTaskHelper.cs"); } IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(primaryUser.OrganizationId), 80, "SplitArchiveFromPrimary", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Common\\recipient\\AuxMailboxTaskHelper.cs"); aduser.UserPrincipalName = RecipientTaskHelper.GenerateUniqueUserPrincipalName(recipientSession, aduser.Alias, tenantOrTopologyConfigurationSession.GetDefaultAcceptedDomain().DomainName.Domain, null); aduser.EmailAddresses.Add(new SmtpProxyAddress(aduser.UserPrincipalName, false)); DatabaseLocationInfo serverForDatabase = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(primaryUser.ArchiveDatabase.ObjectGuid); aduser.ServerLegacyDN = serverForDatabase.ServerLegacyDN; aduser.SetId(primaryUser.Id.Parent.GetChildId(aduser.Name)); } return(aduser); }
protected override void InternalStateReset() { if (string.IsNullOrEmpty(this.Name) && string.IsNullOrEmpty(this.DisplayName)) { base.WriteError(new RecipientTaskException(Strings.ErrorNewTeamMailboxParameter), ExchangeErrorCategory.Client, null); } IList <TeamMailboxProvisioningPolicy> teamMailboxPolicies = this.GetTeamMailboxPolicies(); if (teamMailboxPolicies == null || teamMailboxPolicies.Count == 0) { base.WriteError(new RecipientTaskException(Strings.ErrorTeamMailboxCanNotLoadPolicy), ExchangeErrorCategory.Client, null); } this.provisioningPolicy = teamMailboxPolicies[0]; if (string.IsNullOrEmpty(this.Name)) { string prefix = null; if (!string.IsNullOrEmpty(this.provisioningPolicy.AliasPrefix)) { prefix = this.provisioningPolicy.AliasPrefix; } else if (this.provisioningPolicy.DefaultAliasPrefixEnabled) { prefix = (Datacenter.IsMicrosoftHostedOnly(true) ? "SMO-" : "SM-"); } this.Name = TeamMailboxHelper.GenerateUniqueAliasForSiteMailbox(base.TenantGlobalCatalogSession, base.CurrentOrganizationId, this.DisplayName, prefix, Datacenter.IsMicrosoftHostedOnly(true), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); } if (Datacenter.IsMicrosoftHostedOnly(true)) { SiteMailboxAddressesTemplate siteMailboxAddressesTemplate = null; try { siteMailboxAddressesTemplate = SiteMailboxAddressesTemplate.GetSiteMailboxAddressesTemplate(this.ConfigurationSession, base.ProvisioningCache); } catch (ErrorSiteMailboxCannotLoadAddressTemplateException exception) { base.WriteError(exception, ExchangeErrorCategory.Client, null); } base.UserPrincipalName = RecipientTaskHelper.GenerateUniqueUserPrincipalName(base.TenantGlobalCatalogSession, this.Name, siteMailboxAddressesTemplate.UserPrincipalNameDomain, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); base.UserSpecifiedParameters["SpecificAddressTemplates"] = siteMailboxAddressesTemplate.AddressTemplates; } base.InternalStateReset(); }