Exemple #1
0
        internal static LegacyDN CreateSelfRedirectLegacyDN(LegacyDN legacyDN, Guid mailboxGuid)
        {
            string   rdnPrefix;
            string   str;
            LegacyDN parentLegacyDN = legacyDN.GetParentLegacyDN(out rdnPrefix, out str);

            return(parentLegacyDN.GetChildLegacyDN("cn", ExchangeRpcClientAccess.selfRedirectLegacyDNSectionPrefix + mailboxGuid.ToString()).GetChildLegacyDN(rdnPrefix, ExchangeRpcClientAccess.selfRedirectLegacyDNServerPrefix + str));
        }
Exemple #2
0
 public static string CalculateServerLegacyDNFromPfdbLegacyDN(string pfdbLegacyDN)
 {
     if (string.IsNullOrEmpty(pfdbLegacyDN))
     {
         throw new ArgumentNullException("pfdbLegacyDN");
     }
     return(Database.GetRcaLegacyDNFromDatabaseLegacyDN(LegacyDN.Parse(pfdbLegacyDN)).ToString());
 }
Exemple #3
0
        internal static string FixFakeRedirectLegacyDNIfNeeded(string legacyDN)
        {
            LegacyDN legacyDN2;

            if (!LegacyDN.TryParse(legacyDN, out legacyDN2))
            {
                return(legacyDN);
            }
            return(ExchangeRpcClientAccess.FixFakeRedirectLegacyDNIfNeeded(legacyDN2).ToString());
        }
        private static bool IsValidLegacyDN(string address)
        {
            if (string.IsNullOrEmpty(address))
            {
                throw new ArgumentNullException("address");
            }
            LegacyDN legacyDN;

            return(LegacyDN.TryParse(address, out legacyDN));
        }
Exemple #5
0
        private static Guid GetMailboxGuidFromPersonalizedLegacyDN(string personalizedMailboxLegacyDN)
        {
            Guid     empty = Guid.Empty;
            LegacyDN legacyDN;

            if (!string.IsNullOrWhiteSpace(personalizedMailboxLegacyDN) && LegacyDN.TryParse(personalizedMailboxLegacyDN, out legacyDN))
            {
                string text;
                string address;
                legacyDN.GetParentLegacyDN(out text, out address);
                GuidHelper.TryParseGuid(new SmtpAddress(address).Local, out empty);
            }
            return(empty);
        }
Exemple #6
0
        private static int GetAddressListEphemeralId(NspiRpcClientConnection nspiRpcClientConnection, Guid addressListObjectGuid)
        {
            string text = LegacyDN.FormatLegacyDnFromGuid(Guid.Empty, addressListObjectGuid);

            int[] array;
            int   num = nspiRpcClientConnection.RpcClient.DNToEph(new string[]
            {
                text
            }, out array);

            if (num != 0)
            {
                throw new NspiFailureException(num);
            }
            return(array[0]);
        }
Exemple #7
0
        protected override IConfigurable PrepareDataObject()
        {
            IConfigurationSession configurationSession = base.DataSession as IConfigurationSession;
            bool useConfigNC = configurationSession.UseConfigNC;

            configurationSession.UseConfigNC = false;
            try
            {
                this.ou = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.OrganizationalUnit, configurationSession, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(this.OrganizationalUnit.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(this.OrganizationalUnit.ToString())));
                this.ouOriginatingServer = this.ou.OriginatingServer;
            }
            finally
            {
                configurationSession.UseConfigNC = useConfigNC;
            }
            ExchangeConfigurationUnit     exchangeConfigurationUnit    = (ExchangeConfigurationUnit)base.PrepareDataObject();
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 290, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\DirectorySetup\\InstallTenantConfigurationContainerTask.cs");
            string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}{1}", new object[]
            {
                topologyConfigurationSession.GetAdministrativeGroup().LegacyExchangeDN,
                this.GetRelativeDNTillConfigurationUnits(exchangeConfigurationUnit.Id)
            });

            exchangeConfigurationUnit.Name               = exchangeConfigurationUnit.Id.Rdn.UnescapedName;
            exchangeConfigurationUnit.LegacyExchangeDN   = LegacyDN.GenerateLegacyDN(parentLegacyDN, exchangeConfigurationUnit);
            exchangeConfigurationUnit.OrganizationStatus = OrganizationStatus.PendingCompletion;
            if (!string.IsNullOrEmpty(this.ServicePlan))
            {
                exchangeConfigurationUnit.ServicePlan = this.ServicePlan;
            }
            if (!string.IsNullOrEmpty(this.ProgramId) && !string.IsNullOrEmpty(this.OfferId))
            {
                exchangeConfigurationUnit.ResellerId = string.Format("{0}.{1}", this.ProgramId, this.OfferId);
                if (this.CreateSharedConfiguration)
                {
                    this.DataObject.SharedConfigurationInfo = SharedConfigurationInfo.FromInstalledVersion(this.ProgramId, this.OfferId);
                }
            }
            if (string.IsNullOrEmpty(exchangeConfigurationUnit.ExternalDirectoryOrganizationId))
            {
                exchangeConfigurationUnit.ExternalDirectoryOrganizationId = Guid.NewGuid().ToString();
            }
            return(exchangeConfigurationUnit);
        }
Exemple #8
0
        private static ADUser GetAdUser(IRecipientSession recipientSession, string scope, bool throwIfNotFound)
        {
            LegacyDN legacyDN;
            ADUser   aduser;

            if (LegacyDN.TryParse(scope, out legacyDN))
            {
                aduser = (recipientSession.FindByLegacyExchangeDN(scope) as ADUser);
            }
            else
            {
                aduser = recipientSession.FindADUserByExternalDirectoryObjectId(scope);
            }
            if (aduser == null && throwIfNotFound)
            {
                throw new ComplianceTaskPermanentException("Recipient not found: " + scope, UnifiedPolicyErrorCode.FailedToOpenContainer);
            }
            return(aduser);
        }
Exemple #9
0
        protected override IConfigurable PrepareDataObject()
        {
            this.DataObject = (OfflineAddressBook)base.PrepareDataObject();
            MultiValuedProperty <OfflineAddressBookVersion> multiValuedProperty = new MultiValuedProperty <OfflineAddressBookVersion>();

            multiValuedProperty.Add(OfflineAddressBookVersion.Version4);
            this.DataObject.Versions             = multiValuedProperty;
            this.DataObject.ConfiguredAttributes = OfflineAddressBookMapiProperty.DefaultOABPropertyList;
            this.DataObject.UpdateRawMapiAttributes(false);
            if (base.Fields.IsModified("GeneratingMailbox"))
            {
                this.DataObject.GeneratingMailbox = OfflineAddressBookTaskUtility.ValidateGeneratingMailbox(base.TenantGlobalCatalogSession, this.GeneratingMailbox, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADUser>), this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            this.DataObject.AddressLists = OfflineAddressBookTaskUtility.ValidateAddressBook(base.DataSession, this.AddressLists, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
            this.DataObject.PublicFolderDistributionEnabled = false;
            this.DataObject.PublicFolderDatabase            = null;
            if (this.VirtualDirectories != null && this.VirtualDirectories.Length != 0)
            {
                this.DataObject.VirtualDirectories = OfflineAddressBookTaskUtility.ValidateVirtualDirectory(base.GlobalConfigSession, this.VirtualDirectories, new OfflineAddressBookTaskUtility.GetUniqueObject(base.GetDataObject <ADOabVirtualDirectory>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (base.Fields.IsModified("GlobalWebDistributionEnabled"))
            {
                this.DataObject.GlobalWebDistributionEnabled = this.GlobalWebDistributionEnabled;
            }
            if (base.Fields.IsModified("ShadowMailboxDistributionEnabled"))
            {
                this.DataObject.ShadowMailboxDistributionEnabled = this.ShadowMailboxDistributionEnabled;
            }
            this.DataObject.Server = ((IConfigurationSession)base.DataSession).GetOrgContainerId().GetDescendantId(this.DataObject.ParentPath);
            if (!this.DataObject.IsModified(OfflineAddressBookSchema.IsDefault) && ((IConfigurationSession)base.DataSession).Find <OfflineAddressBook>(null, QueryScope.SubTree, null, null, 1).Length == 0)
            {
                this.DataObject.IsDefault = true;
            }
            this.DataObject.SetId((IConfigurationSession)base.DataSession, base.Name);
            string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/cn=addrlists/cn=oabs", new object[]
            {
                ((IConfigurationSession)base.DataSession).GetOrgContainer().LegacyExchangeDN
            });

            this.DataObject[OfflineAddressBookSchema.ExchangeLegacyDN] = LegacyDN.GenerateLegacyDN(parentLegacyDN, this.DataObject, true, new LegacyDN.LegacyDNIsUnique(this.LegacyDNIsUnique));
            OfflineAddressBookTaskUtility.WarnForNoDistribution(this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            return(this.DataObject);
        }
Exemple #10
0
        internal RfriStatus GetFQDNFromLegacyDN(string legacyDN, out string serverFQDN)
        {
            RfriStatus rfriStatus = RfriStatus.Success;

            serverFQDN = null;
            RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "Requested DN: {0}", RfriContext.GetString(legacyDN));
            if (legacyDN.Contains("@"))
            {
                LegacyDN legacyDN2;
                if (LegacyDN.TryParse(legacyDN, out legacyDN2))
                {
                    string text;
                    legacyDN2.GetParentLegacyDN(out text, out serverFQDN);
                    if (string.IsNullOrEmpty(serverFQDN) || !serverFQDN.Contains("@"))
                    {
                        rfriStatus = RfriStatus.NoSuchObject;
                    }
                }
                else
                {
                    rfriStatus = RfriStatus.NoSuchObject;
                }
            }
            else
            {
                legacyDN   = ExchangeRpcClientAccess.FixFakeRedirectLegacyDNIfNeeded(legacyDN);
                rfriStatus = ServerFqdnCache.LookupFQDNByLegacyDN(legacyDN, out serverFQDN);
            }
            if (rfriStatus != RfriStatus.Success || string.IsNullOrEmpty(serverFQDN))
            {
                if (rfriStatus == RfriStatus.Success)
                {
                    rfriStatus = RfriStatus.NoSuchObject;
                }
                this.ProtocolLogSession[ProtocolLog.Field.Failures] = RfriContext.GetString(legacyDN);
            }
            else
            {
                RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "Referring to {0}", serverFQDN);
            }
            return(rfriStatus);
        }
Exemple #11
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (string.IsNullOrEmpty(this.DataObject.LegacyExchangeDN))
     {
         AdministrativeGroup administrativeGroup = base.GlobalConfigSession.GetAdministrativeGroup();
         string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/cn=Recipients", new object[]
         {
             administrativeGroup.LegacyExchangeDN
         });
         this.DataObject.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, this.DataObject, true, new LegacyDN.LegacyDNIsUnique(this.LegacyDNIsUnique));
     }
     if (!VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.EmailAddressPolicy.Enabled)
     {
         this.DataObject.EmailAddressPolicyEnabled = false;
     }
     DistributionGroupTaskHelper.CheckModerationInMixedEnvironment(this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning), Strings.WarningLegacyExchangeServer);
     TaskLogger.LogExit();
 }
Exemple #12
0
 internal static LegacyDN FixFakeRedirectLegacyDNIfNeeded(LegacyDN legacyDN)
 {
     try
     {
         string   rdnPrefix;
         string   text;
         LegacyDN parentLegacyDN = legacyDN.GetParentLegacyDN(out rdnPrefix, out text);
         string   text2;
         string   text3;
         LegacyDN parentLegacyDN2 = parentLegacyDN.GetParentLegacyDN(out text2, out text3);
         if (text3 != null && text3.StartsWith(ExchangeRpcClientAccess.selfRedirectLegacyDNSectionPrefix, StringComparison.OrdinalIgnoreCase) && text != null && text.StartsWith(ExchangeRpcClientAccess.selfRedirectLegacyDNServerPrefix, StringComparison.OrdinalIgnoreCase))
         {
             return(parentLegacyDN2.GetChildLegacyDN(rdnPrefix, text.Substring(ExchangeRpcClientAccess.selfRedirectLegacyDNServerPrefix.Length)));
         }
     }
     catch (FormatException)
     {
     }
     return(legacyDN);
 }
 private NspiPrincipal(ADUser adUser)
 {
     this.LegacyDistinguishedName = adUser.LegacyExchangeDN;
     if (string.IsNullOrEmpty(this.LegacyDistinguishedName))
     {
         this.LegacyDistinguishedName = LegacyDN.FormatLegacyDnFromGuid(Guid.Empty, adUser.Guid);
     }
     this.AddressBookPolicy   = adUser.AddressBookPolicy;
     this.OrganizationId      = adUser.OrganizationId;
     this.DirectorySearchRoot = adUser.QueryBaseDN;
     this.PrimarySmtpAddress  = adUser.PrimarySmtpAddress;
     this.ExchangeGuid        = adUser.ExchangeGuid;
     this.MAPIEnabled         = adUser.MAPIEnabled;
     this.Database            = adUser.Database;
     this.ExchangeVersion     = adUser.ExchangeVersion;
     if (adUser.Languages != null && adUser.Languages.Count > 0)
     {
         this.PreferredCulture = adUser.Languages[0];
     }
 }
 private NspiPrincipal(MiniRecipient miniRecipient)
 {
     this.LegacyDistinguishedName = miniRecipient.LegacyExchangeDN;
     if (string.IsNullOrEmpty(this.LegacyDistinguishedName))
     {
         this.LegacyDistinguishedName = LegacyDN.FormatLegacyDnFromGuid(Guid.Empty, (Guid)miniRecipient[ADObjectSchema.Guid]);
     }
     this.AddressBookPolicy   = miniRecipient.AddressBookPolicy;
     this.OrganizationId      = miniRecipient.OrganizationId;
     this.DirectorySearchRoot = miniRecipient.QueryBaseDN;
     this.PrimarySmtpAddress  = miniRecipient.PrimarySmtpAddress;
     this.ExchangeGuid        = miniRecipient.ExchangeGuid;
     this.MAPIEnabled         = miniRecipient.MAPIEnabled;
     this.Database            = miniRecipient.Database;
     this.ExchangeVersion     = miniRecipient.ExchangeVersion;
     if (miniRecipient.Languages != null && miniRecipient.Languages.Count > 0)
     {
         this.PreferredCulture = miniRecipient.Languages[0];
     }
 }
Exemple #15
0
 private void ValidatePublicFolderParameters()
 {
     this.ValidateRemoteServerConstraint(this.RPCProxyServer, MigrationBatchMessageSchema.MigrationJobExchangeRPCProxyServerHostName, "RpcProxyServer");
     if (!LegacyDN.IsValidLegacyDN(this.SourceMailboxLegacyDN))
     {
         this.WriteError(new InvalidLegacyExchangeDnValueException("SourceMailboxLegacyDN"));
     }
     if (!LegacyDN.IsValidLegacyDN(this.PublicFolderDatabaseServerLegacyDN))
     {
         this.WriteError(new InvalidLegacyExchangeDnValueException("PublicFolderDatabaseServerLegacyDN"));
     }
     this.endpoint = new PublicFolderEndpoint
     {
         RpcProxyServer        = this.RPCProxyServer,
         AuthenticationMethod  = this.Authentication,
         SourceMailboxLegacyDN = this.SourceMailboxLegacyDN,
         PublicFolderDatabaseServerLegacyDN = this.PublicFolderDatabaseServerLegacyDN,
         Credentials = this.Credentials
     };
     this.targetMailbox = TestMigrationServerAvailability.DiscoverPublicFolderTestMailbox(this.TestMailbox, this.ConfigurationSession, this.RecipientSession, base.ServerSettings, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
 }
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            notFoundReason = null;
            IEnumerable <T> result = new List <T>();

            if (typeof(Database).IsAssignableFrom(typeof(T)) && !string.IsNullOrEmpty(base.RawIdentity))
            {
                LegacyDN legacyDN = null;
                if (LegacyDN.TryParse(base.RawIdentity, out legacyDN))
                {
                    QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, DatabaseSchema.ExchangeLegacyDN, base.RawIdentity);
                    result = base.PerformPrimarySearch <T>(filter, rootId, session, true, optionalData);
                }
            }
            else
            {
                result = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            }
            TaskLogger.LogExit();
            return(result);
        }
        internal static ADSystemMailbox SaveSystemMailbox(MailboxDatabase mdb, Server owningServer, ADObjectId rootOrgContainerId, ITopologyConfigurationSession configSession, IRecipientSession recipientSession, ADObjectId[] forcedReplicationSites, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskVerboseLoggingDelegate writeVerbose)
        {
            TaskLogger.LogEnter();
            bool               useConfigNC        = configSession.UseConfigNC;
            bool               useGlobalCatalog   = configSession.UseGlobalCatalog;
            string             text               = "SystemMailbox" + mdb.Guid.ToString("B");
            SecurityIdentifier securityIdentifier = new SecurityIdentifier("SY");
            ADSystemMailbox    adsystemMailbox    = new ADSystemMailbox();

            adsystemMailbox.StampPersistableDefaultValues();
            adsystemMailbox.Name        = text;
            adsystemMailbox.DisplayName = text;
            adsystemMailbox.Alias       = text;
            adsystemMailbox.HiddenFromAddressListsEnabled = true;
            adsystemMailbox.Database = mdb.Id;
            if (owningServer == null)
            {
                throw new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(mdb.Identity.ToString()));
            }
            adsystemMailbox.ServerLegacyDN = owningServer.ExchangeLegacyDN;
            adsystemMailbox.ExchangeGuid   = Guid.NewGuid();
            AcceptedDomain defaultAcceptedDomain = configSession.GetDefaultAcceptedDomain();

            if (defaultAcceptedDomain == null || defaultAcceptedDomain.DomainName == null || defaultAcceptedDomain.DomainName.Domain == null)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorNoDefaultAcceptedDomainFound(mdb.Identity.ToString()));
            }
            adsystemMailbox.EmailAddresses.Add(ProxyAddress.Parse("SMTP:" + adsystemMailbox.Alias + "@" + defaultAcceptedDomain.DomainName.Domain.ToString()));
            adsystemMailbox.WindowsEmailAddress         = adsystemMailbox.PrimarySmtpAddress;
            adsystemMailbox.SendModerationNotifications = TransportModerationNotificationFlags.Never;
            Organization organization = configSession.Read <Organization>(rootOrgContainerId);

            if (organization == null)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorOrganizationNotFound(rootOrgContainerId.Name));
            }
            string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/ou={1}/cn=Recipients", new object[]
            {
                organization.LegacyExchangeDN,
                configSession.GetAdministrativeGroupId().Name
            });

            adsystemMailbox.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, adsystemMailbox);
            ADComputer adcomputer;

            try
            {
                configSession.UseConfigNC      = false;
                configSession.UseGlobalCatalog = true;
                adcomputer = configSession.FindComputerByHostName(owningServer.Name);
            }
            finally
            {
                configSession.UseConfigNC      = useConfigNC;
                configSession.UseGlobalCatalog = useGlobalCatalog;
            }
            if (adcomputer == null)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorDBOwningServerNotFound(mdb.Identity.ToString()));
            }
            ADObjectId adobjectId = adcomputer.Id.DomainId;

            adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects");
            adsystemMailbox.SetId(adobjectId.GetChildId(text));
            GenericAce[] aces = new GenericAce[]
            {
                new CommonAce(AceFlags.None, AceQualifier.AccessAllowed, 131075, securityIdentifier, false, null)
            };
            DirectoryCommon.SetAclOnAlternateProperty(adsystemMailbox, aces, ADSystemAttendantMailboxSchema.ExchangeSecurityDescriptor, securityIdentifier, securityIdentifier);
            recipientSession.LinkResolutionServer = mdb.OriginatingServer;
            bool enforceDefaultScope = recipientSession.EnforceDefaultScope;

            try
            {
                writeVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(adsystemMailbox, recipientSession, typeof(ADSystemMailbox)));
                recipientSession.EnforceDefaultScope = false;
                recipientSession.Save(adsystemMailbox);
            }
            catch (ADConstraintViolationException ex)
            {
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ex.Server, false, ConsistencyMode.PartiallyConsistent, configSession.SessionSettings, 705, "SaveSystemMailbox", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\database\\NewMailboxDatabase.cs");
                if (!tenantOrTopologyConfigurationSession.ReplicateSingleObjectToTargetDC(mdb, ex.Server))
                {
                    throw;
                }
                writeVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(adsystemMailbox, recipientSession, typeof(ADSystemMailbox)));
                recipientSession.Save(adsystemMailbox);
            }
            finally
            {
                writeVerbose(TaskVerboseStringHelper.GetSourceVerboseString(recipientSession));
                recipientSession.EnforceDefaultScope = enforceDefaultScope;
            }
            if (forcedReplicationSites != null)
            {
                DagTaskHelper.ForceReplication(recipientSession, adsystemMailbox, forcedReplicationSites, mdb.Name, writeWarning, writeVerbose);
            }
            TaskLogger.LogExit();
            return(adsystemMailbox);
        }
Exemple #18
0
 internal void StampLegacyExchangeDN(string orgLegDN, string agName)
 {
     this[AdministrativeGroupSchema.LegacyExchangeDN] = string.Format("{0}/ou={1}", orgLegDN, LegacyDN.LegitimizeCN(agName));
 }
Exemple #19
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            bool          flag         = false;
            MigrationType endpointType = this.DataObject.EndpointType;

            if (endpointType <= MigrationType.ExchangeOutlookAnywhere)
            {
                if (endpointType == MigrationType.IMAP)
                {
                    this.WriteParameterErrorIfSet("Credentials");
                    this.WriteParameterErrorIfSet("MailboxPermission");
                    this.WriteParameterErrorIfSet("ExchangeServer");
                    this.WriteParameterErrorIfSet("RPCProxyServer");
                    this.WriteParameterErrorIfSet("NspiServer");
                    this.WriteParameterErrorIfSet("PublicFolderDatabaseServerLegacyDN");
                    this.WriteParameterErrorIfSet("TestMailbox", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("SourceMailboxLegacyDN", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("EmailAddress", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    goto IL_2B4;
                }
                if (endpointType == MigrationType.ExchangeOutlookAnywhere)
                {
                    this.WriteParameterErrorIfSet("Port");
                    this.WriteParameterErrorIfSet("Security");
                    this.WriteParameterErrorIfSet("PublicFolderDatabaseServerLegacyDN");
                    goto IL_2B4;
                }
            }
            else
            {
                if (endpointType == MigrationType.ExchangeRemoteMove)
                {
                    this.WriteParameterErrorIfSet("ExchangeServer");
                    this.WriteParameterErrorIfSet("RPCProxyServer");
                    this.WriteParameterErrorIfSet("Port");
                    this.WriteParameterErrorIfSet("MailboxPermission");
                    this.WriteParameterErrorIfSet("Authentication");
                    this.WriteParameterErrorIfSet("Security");
                    this.WriteParameterErrorIfSet("NspiServer");
                    this.WriteParameterErrorIfSet("PublicFolderDatabaseServerLegacyDN");
                    this.WriteParameterErrorIfSet("TestMailbox", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("SourceMailboxLegacyDN", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("EmailAddress", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    goto IL_2B4;
                }
                if (endpointType == MigrationType.PSTImport)
                {
                    this.WriteParameterErrorIfSet("ExchangeServer");
                    this.WriteParameterErrorIfSet("RPCProxyServer");
                    this.WriteParameterErrorIfSet("Port");
                    this.WriteParameterErrorIfSet("MailboxPermission");
                    this.WriteParameterErrorIfSet("Authentication");
                    this.WriteParameterErrorIfSet("Security");
                    this.WriteParameterErrorIfSet("NspiServer");
                    this.WriteParameterErrorIfSet("PublicFolderDatabaseServerLegacyDN");
                    this.WriteParameterErrorIfSet("TestMailbox", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("SourceMailboxLegacyDN", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    this.WriteParameterErrorIfSet("EmailAddress", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    goto IL_2B4;
                }
                if (endpointType == MigrationType.PublicFolder)
                {
                    this.WriteParameterErrorIfSet("RemoteServer");
                    this.WriteParameterErrorIfSet("ExchangeServer");
                    this.WriteParameterErrorIfSet("Port");
                    this.WriteParameterErrorIfSet("MailboxPermission");
                    this.WriteParameterErrorIfSet("Security");
                    this.WriteParameterErrorIfSet("NspiServer");
                    this.WriteParameterErrorIfSet("EmailAddress", new LocalizedString?(Strings.ErrorInvalidEndpointParameterReasonUsedForConnectionTest));
                    goto IL_2B4;
                }
            }
            base.WriteError(new InvalidEndpointTypeException(this.Identity.RawIdentity, this.DataObject.EndpointType.ToString()));
IL_2B4:
            if (base.IsFieldSet("MaxConcurrentMigrations") || base.IsFieldSet("MaxConcurrentIncrementalSyncs"))
            {
                Unlimited <int> unlimited  = base.IsFieldSet("MaxConcurrentMigrations") ? this.MaxConcurrentMigrations : this.DataObject.MaxConcurrentMigrations;
                Unlimited <int> unlimited2 = base.IsFieldSet("MaxConcurrentIncrementalSyncs") ? this.MaxConcurrentIncrementalSyncs : this.DataObject.MaxConcurrentIncrementalSyncs;
                if (unlimited2 > unlimited)
                {
                    base.WriteError(new MigrationMaxConcurrentIncrementalSyncsVerificationFailedException(unlimited2, unlimited));
                }
            }
            if (base.IsFieldSet("MaxConcurrentMigrations") && !this.MaxConcurrentMigrations.Equals(this.DataObject.MaxConcurrentMigrations))
            {
                this.DataObject.MaxConcurrentMigrations = this.MaxConcurrentMigrations;
                this.changed = true;
            }
            if (base.IsFieldSet("MaxConcurrentIncrementalSyncs") && !this.MaxConcurrentIncrementalSyncs.Equals(this.DataObject.MaxConcurrentIncrementalSyncs))
            {
                this.DataObject.MaxConcurrentIncrementalSyncs = this.MaxConcurrentIncrementalSyncs;
                this.changed = true;
            }
            if (base.IsFieldSet("Credentials") && (this.Credentials == null || !this.Credentials.Equals(this.DataObject.Credentials)))
            {
                this.DataObject.Credentials = this.Credentials;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("MailboxPermission") && this.MailboxPermission != this.DataObject.MailboxPermission)
            {
                this.DataObject.MailboxPermission = this.MailboxPermission;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("ExchangeServer") && !this.ExchangeServer.Equals(this.DataObject.ExchangeServer))
            {
                this.DataObject.ExchangeServer = this.ExchangeServer;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("RPCProxyServer") && !this.RpcProxyServer.Equals(this.DataObject.RpcProxyServer))
            {
                this.DataObject.RpcProxyServer = this.RpcProxyServer;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("Port") && !this.Port.Equals(this.DataObject.Port))
            {
                this.DataObject.Port = new int?(this.Port);
                this.changed         = true;
                flag = true;
            }
            if (base.IsFieldSet("Authentication") && !this.Authentication.Equals(this.DataObject.Authentication))
            {
                this.DataObject.Authentication = new AuthenticationMethod?(this.Authentication);
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("Security") && !this.Security.Equals(this.DataObject.Security))
            {
                this.DataObject.Security = new IMAPSecurityMechanism?(this.Security);
                this.changed             = true;
                flag = true;
            }
            if (base.IsFieldSet("RemoteServer") && !this.RemoteServer.Equals(this.DataObject.RemoteServer))
            {
                this.DataObject.RemoteServer = this.RemoteServer;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("NspiServer") && !this.NspiServer.Equals(this.DataObject.NspiServer))
            {
                this.DataObject.NspiServer = this.NspiServer;
                this.changed = true;
                flag         = true;
            }
            if (this.DataObject.EndpointType == MigrationType.PublicFolder && base.IsFieldSet("SourceMailboxLegacyDN") && !this.SourceMailboxLegacyDN.Equals(this.DataObject.SourceMailboxLegacyDN))
            {
                if (!LegacyDN.IsValidLegacyDN(this.SourceMailboxLegacyDN))
                {
                    base.WriteError(new InvalidLegacyExchangeDnValueException("SourceMailboxLegacyDN"));
                }
                this.DataObject.SourceMailboxLegacyDN = this.SourceMailboxLegacyDN;
                this.changed = true;
                flag         = true;
            }
            if (base.IsFieldSet("PublicFolderDatabaseServerLegacyDN") && !this.PublicFolderDatabaseServerLegacyDN.Equals(this.DataObject.PublicFolderDatabaseServerLegacyDN))
            {
                if (!LegacyDN.IsValidLegacyDN(this.PublicFolderDatabaseServerLegacyDN))
                {
                    base.WriteError(new InvalidLegacyExchangeDnValueException("PublicFolderDatabaseServerLegacyDN"));
                }
                this.DataObject.PublicFolderDatabaseServerLegacyDN = this.PublicFolderDatabaseServerLegacyDN;
                this.changed = true;
                flag         = true;
            }
            if (flag)
            {
                this.DataObject.LastModifiedTime = (DateTime)ExDateTime.UtcNow;
            }
            if (!this.SkipVerification)
            {
                MigrationEndpointBase migrationEndpointBase = MigrationEndpointBase.CreateFrom(this.DataObject);
                migrationEndpointBase.VerifyConnectivity();
                if (this.DataObject.EndpointType == MigrationType.ExchangeOutlookAnywhere)
                {
                    ExchangeOutlookAnywhereEndpoint exchangeOutlookAnywhereEndpoint = (ExchangeOutlookAnywhereEndpoint)migrationEndpointBase;
                    if (!string.IsNullOrEmpty(this.SourceMailboxLegacyDN) || this.EmailAddress != SmtpAddress.Empty || !string.IsNullOrEmpty(exchangeOutlookAnywhereEndpoint.EmailAddress))
                    {
                        MailboxData targetMailbox = TestMigrationServerAvailability.DiscoverTestMailbox(this.TestMailbox, ((MigrationADProvider)this.DataProvider.ADProvider).RecipientSession, base.ServerSettings, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
                        string      text          = (string)this.EmailAddress;
                        if (string.IsNullOrEmpty(text))
                        {
                            text = exchangeOutlookAnywhereEndpoint.EmailAddress;
                        }
                        TestMigrationServerAvailability.VerifyExchangeOutlookAnywhereConnection(this.DataProvider, exchangeOutlookAnywhereEndpoint, text, this.SourceMailboxLegacyDN, targetMailbox, false);
                        return;
                    }
                }
                else if (this.DataObject.EndpointType == MigrationType.PublicFolder)
                {
                    MailboxData mailboxData = TestMigrationServerAvailability.DiscoverPublicFolderTestMailbox(this.TestMailbox, this.ConfigurationSession, ((MigrationADProvider)this.DataProvider.ADProvider).RecipientSession, base.ServerSettings, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
                    TestMigrationServerAvailability.VerifyPublicFolderConnection(this.DataProvider, (PublicFolderEndpoint)migrationEndpointBase, this.SourceMailboxLegacyDN, this.PublicFolderDatabaseServerLegacyDN, mailboxData);
                }
            }
        }
Exemple #20
0
        internal static void CalculatePreferredHomeServerInternal(ActiveManager activeManager, IADDatabase database, ITopologyConfigurationSession adSession, IFindAdObject <IADDatabaseAvailabilityGroup> dagLookup, IFindAdObject <IADClientAccessArray> findClientAccessArray, IFindMiniClientAccessServerOrArray findMiniClientAccessServer, out LegacyDN preferredRpcClientAccessServerLegacyDN, out ADObjectId preferredServerSite)
        {
            Util.ThrowOnNullArgument(activeManager, "activeManager");
            preferredRpcClientAccessServerLegacyDN = LegacyDN.Parse(database.RpcClientAccessServerLegacyDN);
            ADObjectId masterServerOrAvailabilityGroup = database.MasterServerOrAvailabilityGroup;
            IADDatabaseAvailabilityGroup iaddatabaseAvailabilityGroup = (masterServerOrAvailabilityGroup != null) ? dagLookup.ReadAdObjectByObjectId(masterServerOrAvailabilityGroup) : null;

            if (iaddatabaseAvailabilityGroup == null || !iaddatabaseAvailabilityGroup.AllowCrossSiteRpcClientAccess)
            {
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId, ADObjectId>((long)activeManager.GetHashCode(), "CalculatePreferredHomeServerInternal: Cross-site is not allowed. Database = '{0}', DAG = '{1}'", database.Id, masterServerOrAvailabilityGroup);
                DatabaseLocationInfo databaseLocationInfo = null;
                preferredServerSite = null;
                try
                {
                    databaseLocationInfo = activeManager.GetServerForDatabase(database.Guid, GetServerForDatabaseFlags.IgnoreAdSiteBoundary, NullPerformanceDataLogger.Instance);
                    if (databaseLocationInfo != null)
                    {
                        preferredServerSite = databaseLocationInfo.ServerSite;
                    }
                }
                catch (DatabaseNotFoundException arg)
                {
                    ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId, DatabaseNotFoundException>((long)activeManager.GetHashCode(), "CalculatePreferredHomeServerInternal: The database '{0}' does not exist. Exception = {1}", database.Id, arg);
                    preferredServerSite = null;
                }
                catch (ObjectNotFoundException arg2)
                {
                    ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <ADObjectId, ObjectNotFoundException>((long)activeManager.GetHashCode(), "CalculatePreferredHomeServerInternal: Server hosting the database {0} cannot be found. Exception = {1}", database.Id, arg2);
                    preferredServerSite = null;
                }
                if (preferredServerSite == null)
                {
                    preferredRpcClientAccessServerLegacyDN = null;
                    return;
                }
                IADMiniClientAccessServerOrArray iadminiClientAccessServerOrArray = findMiniClientAccessServer.FindMiniClientAccessServerOrArrayByLegdn(databaseLocationInfo.RpcClientAccessServerLegacyDN);
                if (iadminiClientAccessServerOrArray != null && iadminiClientAccessServerOrArray.ServerSite != null && iadminiClientAccessServerOrArray.ServerSite.Equals(preferredServerSite))
                {
                    preferredRpcClientAccessServerLegacyDN = LegacyDN.Parse(databaseLocationInfo.RpcClientAccessServerLegacyDN);
                    return;
                }
                preferredRpcClientAccessServerLegacyDN = ActiveManagerImplementation.FindClientAccessArrayOrServerFromSite(preferredServerSite, database.HostServerForPreference1, findClientAccessArray, findMiniClientAccessServer, AdObjectLookupFlags.None);
                return;
            }
            else
            {
                IADMiniClientAccessServerOrArray iadminiClientAccessServerOrArray2 = findMiniClientAccessServer.FindMiniClientAccessServerOrArrayByLegdn(preferredRpcClientAccessServerLegacyDN.ToString());
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug <LegacyDN, string>((long)activeManager.GetHashCode(), "CalculatePreferredHomeServerInternal. preferredRpcClientAccessServerLegacyDN = {0}, preferredMiniServer = {1}.", preferredRpcClientAccessServerLegacyDN, (iadminiClientAccessServerOrArray2 == null) ? "<null>" : iadminiClientAccessServerOrArray2.Fqdn);
                if (iadminiClientAccessServerOrArray2 == null)
                {
                    preferredServerSite = null;
                    preferredRpcClientAccessServerLegacyDN = null;
                    return;
                }
                preferredRpcClientAccessServerLegacyDN = LegacyDN.Parse(iadminiClientAccessServerOrArray2.ExchangeLegacyDN);
                preferredServerSite = iadminiClientAccessServerOrArray2.ServerSite;
                return;
            }
        }
        // Token: 0x060008D4 RID: 2260 RVA: 0x0001EDC8 File Offset: 0x0001CFC8
        protected ServerIdParameter(string identity) : base(identity)
        {
            if (base.InternalADObjectId != null)
            {
                return;
            }
            LegacyDN legacyDN;

            if (!ADObjectNameHelper.ReservedADNameStringRegex.IsMatch(identity) && !ServerIdParameter.IsValidName(identity) && !ServerIdParameter.IsValidFqdn(identity) && !LegacyDN.TryParse(identity, out legacyDN))
            {
                throw new ArgumentException(Strings.ErrorInvalidIdentity(identity), "identity");
            }
            this.fqdn = identity;
            if (identity.EndsWith(".", StringComparison.Ordinal))
            {
                this.fqdn = identity.Substring(0, identity.Length - 1);
            }
        }
        private static bool IsValidExAddress(string address)
        {
            LegacyDN legacyDN;

            return(LegacyDN.TryParse(address, out legacyDN));
        }
Exemple #23
0
        internal static LegacyDN CreatePersonalizedServerRedirectLegacyDN(LegacyDN legacyDN, Guid mailboxGuid, string domain)
        {
            LegacyDN parentLegacyDN = legacyDN.GetParentLegacyDN();

            return(parentLegacyDN.GetChildLegacyDN("cn", ExchangeRpcClientAccess.CreatePersonalizedServer(mailboxGuid, domain)));
        }