public static void ValidateExternalEmailAddress(ADContact contact, IConfigurationSession configurationSession, Task.ErrorLoggerDelegate writeError, ProvisioningCache provisioningCache)
 {
     if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.ValidateExternalEmailAddressInAcceptedDomain.Enabled)
     {
         SmtpProxyAddress smtpProxyAddress = contact.ExternalEmailAddress as SmtpProxyAddress;
         if (smtpProxyAddress == null)
         {
             writeError(new RecipientTaskException(Strings.ErrorExternalEmailAddressNotSmtpAddress((contact.ExternalEmailAddress == null) ? "$null" : contact.ExternalEmailAddress.ToString())), ExchangeErrorCategory.Client, contact.Identity);
             return;
         }
         if (RecipientTaskHelper.SMTPAddressCheckWithAcceptedDomain(configurationSession, contact.OrganizationId, writeError, provisioningCache))
         {
             string domain = new SmtpAddress(smtpProxyAddress.SmtpAddress).Domain;
             if (RecipientTaskHelper.IsAcceptedDomain(configurationSession, contact.OrganizationId, domain, provisioningCache))
             {
                 writeError(new RecipientTaskException(Strings.ErrorIsAcceptedDomain(domain)), ExchangeErrorCategory.Client, null);
             }
         }
         contact.EmailAddressPolicyEnabled = false;
         if (contact.PrimarySmtpAddress == SmtpAddress.Empty)
         {
             contact.PrimarySmtpAddress = new SmtpAddress(smtpProxyAddress.SmtpAddress);
         }
     }
 }
Beispiel #2
0
 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();
 }