Beispiel #1
0
        private void ValidateParameters()
        {
            if (this.DomainName == null || string.IsNullOrEmpty(this.DomainName.Domain))
            {
                base.WriteError(new NoAccountNamespaceException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (this.DataObject.DelegationTrustLink == null || this.DataObject.AccountNamespace == null || string.IsNullOrEmpty(this.DataObject.AccountNamespace.Domain))
            {
                base.WriteError(new NoTrustConfiguredException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            ADObjectId deletedObjectsContainer = base.GlobalConfigSession.DeletedObjectsContainer;
            ADObjectId adobjectId = ADObjectIdResolutionHelper.ResolveDN(this.DataObject.DelegationTrustLink);

            if (adobjectId.Parent.Equals(deletedObjectsContainer))
            {
                base.WriteError(new NoTrustConfiguredException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            this.federationTrust = base.GlobalConfigSession.Read <FederationTrust>(adobjectId);
            if (this.federationTrust == null)
            {
                base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorFederationTrustNotFound(adobjectId.ToDNString())), ErrorCategory.ObjectNotFound, null);
            }
            this.matchedAcceptedDomain = base.GetAcceptedDomain(this.DomainName, false);
            if (this.matchedAcceptedDomain.FederatedOrganizationLink != null && !this.matchedAcceptedDomain.FederatedOrganizationLink.Parent.Equals(deletedObjectsContainer))
            {
                base.WriteError(new DomainAlreadyFederatedException(this.DomainName.Domain), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            TaskLogger.LogExit();
        }
Beispiel #2
0
 internal static MoveRequest FromDataObject(ADUser dataObject)
 {
     if (dataObject == null)
     {
         return(null);
     }
     if (dataObject.Database != null)
     {
         dataObject.Database = ADObjectIdResolutionHelper.ResolveDN(dataObject.Database);
     }
     if (dataObject.ArchiveDatabase != null)
     {
         dataObject.ArchiveDatabase = ADObjectIdResolutionHelper.ResolveDN(dataObject.ArchiveDatabase);
     }
     if (dataObject.MailboxMoveSourceMDB != null)
     {
         dataObject.MailboxMoveSourceMDB = ADObjectIdResolutionHelper.ResolveDN(dataObject.MailboxMoveSourceMDB);
     }
     if (dataObject.MailboxMoveTargetMDB != null)
     {
         dataObject.MailboxMoveTargetMDB = ADObjectIdResolutionHelper.ResolveDN(dataObject.MailboxMoveTargetMDB);
     }
     if (dataObject.MailboxMoveSourceArchiveMDB != null)
     {
         dataObject.MailboxMoveSourceArchiveMDB = ADObjectIdResolutionHelper.ResolveDN(dataObject.MailboxMoveSourceArchiveMDB);
     }
     if (dataObject.MailboxMoveTargetArchiveMDB != null)
     {
         dataObject.MailboxMoveTargetArchiveMDB = ADObjectIdResolutionHelper.ResolveDN(dataObject.MailboxMoveTargetArchiveMDB);
     }
     return(new MoveRequest(dataObject));
 }
Beispiel #3
0
 private void ValidateParameters()
 {
     if (this.DomainName == null || string.IsNullOrEmpty(this.DomainName.Domain))
     {
         base.WriteError(new NoAccountNamespaceException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     if (!this.IsDatacenter && (this.DataObject.DelegationTrustLink == null || this.DataObject.AccountNamespace == null || string.IsNullOrEmpty(this.DataObject.AccountNamespace.Domain)))
     {
         base.WriteError(new NoTrustConfiguredException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     if (this.DataObject.DelegationTrustLink == null)
     {
         this.federationTrust = null;
     }
     else
     {
         ADObjectId deletedObjectsContainer = this.ConfigurationSession.DeletedObjectsContainer;
         ADObjectId adobjectId = ADObjectIdResolutionHelper.ResolveDN(this.DataObject.DelegationTrustLink);
         if (adobjectId != null)
         {
             if (adobjectId.Parent.Equals(deletedObjectsContainer))
             {
                 this.WriteWarning(Strings.ErrorFederationTrustNotFound(adobjectId.ToDNString()));
                 this.federationTrust = null;
             }
             else
             {
                 IConfigDataProvider configDataProvider = this.IsDatacenter ? base.GlobalConfigSession : base.DataSession;
                 this.federationTrust = (configDataProvider.Read <FederationTrust>(adobjectId) as FederationTrust);
                 if (this.federationTrust == null)
                 {
                     this.WriteWarning(Strings.ErrorFederationTrustNotFound(adobjectId.ToDNString()));
                 }
             }
         }
         else
         {
             this.WriteWarning(Strings.ErrorFederationTrustNotFound(this.DataObject.DelegationTrustLink.ToDNString()));
             this.federationTrust = null;
         }
     }
     if (!this.IsDatacenter && this.DomainName.Equals(this.DataObject.AccountNamespace) && 1 < base.FederatedAcceptedDomains.Count)
     {
         base.WriteError(new CannotRemoveAccountNamespaceException(this.DomainName.Domain), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     this.matchedAcceptedDomain = base.GetAcceptedDomain(this.DomainName, true);
     if (this.matchedAcceptedDomain.FederatedOrganizationLink == null && !this.DomainName.Equals(this.DataObject.AccountNamespace))
     {
         if (this.Force || this.IsDatacenter)
         {
             this.WriteWarning(Strings.ErrorDomainIsNotFederated(this.DomainName.Domain));
         }
         else
         {
             base.WriteError(new DomainIsNotFederatedException(this.DomainName.Domain), ErrorCategory.InvalidOperation, this.DataObject.Identity);
         }
     }
     TaskLogger.LogExit();
 }
        // Token: 0x06000033 RID: 51 RVA: 0x000034F8 File Offset: 0x000016F8
        internal static Uri GetRedirectUrlForTenantSite(string organization, string redirectTemplate, Uri originalUrl, ExEventLog eventLogger)
        {
            if (organization == null)
            {
                return(null);
            }
            ADSessionSettings sessionSettings;

            try
            {
                Guid externalDirectoryOrganizationId;
                sessionSettings = (Guid.TryParse(organization, out externalDirectoryOrganizationId) ? ADSessionSettings.FromExternalDirectoryOrganizationId(externalDirectoryOrganizationId) : ADSessionSettings.FromTenantCUName(organization));
            }
            catch (CannotResolveTenantNameException)
            {
                return(null);
            }
            catch (CannotResolveExternalDirectoryOrganizationIdException)
            {
                return(null);
            }
            ITenantConfigurationSession session = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 180, "GetRedirectUrlForTenantSite", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\RedirectionModule\\RedirectionHelper.cs");
            ExchangeConfigurationUnit   exchangeConfigurationUnit = RedirectionHelper.ResolveConfigurationUnitByName(organization, session);

            if (exchangeConfigurationUnit == null || exchangeConfigurationUnit.ManagementSiteLink == null)
            {
                return(null);
            }
            ADSite     localSite  = LocalSiteCache.LocalSite;
            ADObjectId adobjectId = ADObjectIdResolutionHelper.ResolveDN(exchangeConfigurationUnit.ManagementSiteLink);

            Logger.LogEvent(eventLogger, TaskEventLogConstants.Tuple_LiveIdRedirection_UsingManagementSiteLink, organization, new object[]
            {
                organization,
                exchangeConfigurationUnit.AdminDisplayVersion,
                exchangeConfigurationUnit.ManagementSiteLink
            });
            if (adobjectId.Equals(localSite.Id))
            {
                return(null);
            }
            foreach (ADObjectId adobjectId2 in localSite.ResponsibleForSites)
            {
                if (adobjectId2.Equals(adobjectId))
                {
                    Logger.LogEvent(eventLogger, TaskEventLogConstants.Tuple_LiveIdRedirection_TargetSitePresentOnResponsibleForSite, organization, new object[]
                    {
                        organization,
                        adobjectId,
                        adobjectId2
                    });
                    return(null);
                }
            }
            return(RedirectionHelper.GetRedirectUrlForTenantSite(adobjectId, redirectTemplate, originalUrl));
        }
 private static void LoadAdditionalPropertiesFromUser(RequestJobBase requestJob)
 {
     if (requestJob.TargetUser != null)
     {
         requestJob.TargetAlias        = requestJob.TargetUser.Alias;
         requestJob.TargetExchangeGuid = (requestJob.TargetIsArchive ? requestJob.TargetUser.ArchiveGuid : requestJob.TargetUser.ExchangeGuid);
         requestJob.TargetDatabase     = ADObjectIdResolutionHelper.ResolveDN(requestJob.TargetIsArchive ? requestJob.TargetUser.ArchiveDatabase : requestJob.TargetUser.Database);
         requestJob.TargetUserId       = requestJob.TargetUser.Id;
     }
 }
Beispiel #6
0
 protected override void SetRequestProperties(TransactionalRequestJob dataObject)
 {
     base.SetRequestProperties(dataObject);
     dataObject.RequestType = MRSRequestType.MailboxImport;
     if (dataObject.WorkloadType == RequestWorkloadType.None)
     {
         if (string.IsNullOrEmpty(this.RemoteHostName))
         {
             dataObject.WorkloadType = RequestWorkloadType.Local;
         }
         else
         {
             dataObject.WorkloadType = RequestWorkloadType.RemotePstIngestion;
         }
     }
     dataObject.ContentCodePage = this.ContentCodePage;
     dataObject.FilePath        = this.FilePath.PathName;
     if (this.user != null)
     {
         dataObject.TargetUserId = this.user.Id;
         dataObject.TargetUser   = this.user;
     }
     if (base.ParameterSetName.Equals("MailboxImportRequest"))
     {
         if (!string.IsNullOrEmpty(this.SourceRootFolder))
         {
             dataObject.SourceRootFolder = this.SourceRootFolder;
         }
         if (!string.IsNullOrEmpty(this.TargetRootFolder))
         {
             dataObject.TargetRootFolder = this.TargetRootFolder;
         }
         if (this.IsArchive)
         {
             dataObject.TargetIsArchive    = true;
             dataObject.TargetExchangeGuid = this.user.ArchiveGuid;
             dataObject.TargetDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.user.ArchiveDatabase);
         }
         else
         {
             dataObject.TargetIsArchive    = false;
             dataObject.TargetExchangeGuid = this.user.ExchangeGuid;
             dataObject.TargetDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.user.Database);
         }
         dataObject.TargetAlias = this.user.Alias;
         if (this.RemoteCredential != null)
         {
             dataObject.RemoteCredential = RequestTaskHelper.GetNetworkCredential(this.RemoteCredential, null);
         }
         if (!string.IsNullOrEmpty(this.RemoteHostName))
         {
             dataObject.RemoteHostName = this.RemoteHostName;
         }
     }
 }
 private static void LoadAdditionalPropertiesFromUser(RequestJobBase requestJob)
 {
     if (requestJob.SourceUser != null)
     {
         requestJob.SourceAlias          = requestJob.SourceUser.Alias;
         requestJob.SourceExchangeGuid   = (requestJob.SourceIsArchive ? requestJob.SourceUser.ArchiveGuid : requestJob.SourceUser.ExchangeGuid);
         requestJob.SourceDatabase       = ADObjectIdResolutionHelper.ResolveDN(requestJob.SourceIsArchive ? requestJob.SourceUser.ArchiveDatabase : requestJob.SourceUser.Database);
         requestJob.RecipientTypeDetails = requestJob.SourceUser.RecipientTypeDetails;
         requestJob.SourceUserId         = requestJob.SourceUser.Id;
     }
 }
        protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject)
        {
            if (dataObject == null)
            {
                return(null);
            }
            ADUser user = (ADUser)dataObject;
            SharedConfiguration sharedConfig = null;

            if (SharedConfiguration.IsDehydratedConfiguration(user.OrganizationId) || (SharedConfiguration.GetSharedConfigurationState(user.OrganizationId) & SharedTenantConfigurationState.Static) != SharedTenantConfigurationState.UnSupported)
            {
                sharedConfig = base.ProvisioningCache.TryAddAndGetOrganizationData <SharedConfiguration>(CannedProvisioningCacheKeys.MailboxSharedConfigCacheKey, user.OrganizationId, () => SharedConfiguration.GetSharedConfiguration(user.OrganizationId));
            }
            if (null != user.MasterAccountSid)
            {
                user.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(user.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                user.ResetChangeTracking();
            }
            Mailbox mailbox = new Mailbox(user);

            mailbox.propertyBag.SetField(MailboxSchema.Database, ADObjectIdResolutionHelper.ResolveDN(mailbox.Database));
            if (sharedConfig != null)
            {
                mailbox.SharedConfiguration = sharedConfig.SharedConfigId.ConfigurationUnit;
                if (mailbox.RoleAssignmentPolicy == null)
                {
                    mailbox.RoleAssignmentPolicy = base.ProvisioningCache.TryAddAndGetOrganizationData <ADObjectId>(CannedProvisioningCacheKeys.MailboxRoleAssignmentPolicyCacheKey, user.OrganizationId, () => sharedConfig.GetSharedRoleAssignmentPolicy());
                }
            }
            else if (mailbox.RoleAssignmentPolicy == null && !mailbox.ExchangeVersion.IsOlderThan(MailboxSchema.RoleAssignmentPolicy.VersionAdded))
            {
                ADObjectId defaultRoleAssignmentPolicy = RBACHelper.GetDefaultRoleAssignmentPolicy(user.OrganizationId);
                if (defaultRoleAssignmentPolicy != null)
                {
                    mailbox.RoleAssignmentPolicy = defaultRoleAssignmentPolicy;
                }
            }
            if (mailbox.SharingPolicy == null && !mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.SharingPolicy))
            {
                mailbox.SharingPolicy = base.GetDefaultSharingPolicyId(user, sharedConfig);
            }
            if (mailbox.RetentionPolicy == null && mailbox.ShouldUseDefaultRetentionPolicy && !mailbox.propertyBag.IsReadOnlyProperty(MailboxSchema.RetentionPolicy))
            {
                mailbox.RetentionPolicy = base.GetDefaultRetentionPolicyId(user, sharedConfig);
            }
            if (mailbox.Database != null && mailbox.UseDatabaseRetentionDefaults)
            {
                this.SetDefaultRetentionValues(mailbox);
            }
            mailbox.AdminDisplayVersion = Microsoft.Exchange.Data.Directory.SystemConfiguration.Server.GetServerVersion(mailbox.ServerName);
            return(mailbox);
        }
Beispiel #9
0
 protected override void SetRequestProperties(TransactionalRequestJob dataObject)
 {
     base.SetRequestProperties(dataObject);
     dataObject.RequestType = MRSRequestType.MailboxRestore;
     if (dataObject.WorkloadType == RequestWorkloadType.None)
     {
         dataObject.WorkloadType = RequestWorkloadType.Local;
     }
     if (this.targetUser != null)
     {
         dataObject.TargetUserId = this.targetUser.Id;
         dataObject.TargetUser   = this.targetUser;
     }
     if (!string.IsNullOrEmpty(this.SourceRootFolder))
     {
         dataObject.SourceRootFolder = this.SourceRootFolder;
     }
     dataObject.SourceIsArchive     = false;
     dataObject.SourceExchangeGuid  = this.sourceMailboxGuid;
     dataObject.SourceDatabase      = this.sourceDatabase;
     dataObject.MailboxRestoreFlags = new MailboxRestoreType?(this.restoreFlags);
     if (!string.IsNullOrEmpty(this.TargetRootFolder))
     {
         dataObject.TargetRootFolder = this.TargetRootFolder;
     }
     if (this.TargetIsArchive)
     {
         dataObject.TargetIsArchive    = true;
         dataObject.TargetExchangeGuid = this.targetUser.ArchiveGuid;
         dataObject.TargetDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.targetUser.ArchiveDatabase);
     }
     else
     {
         dataObject.TargetIsArchive    = false;
         dataObject.TargetExchangeGuid = this.targetUser.ExchangeGuid;
         dataObject.TargetDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.targetUser.Database);
     }
     dataObject.TargetAlias         = this.targetUser.Alias;
     dataObject.AllowedToFinishMove = true;
     if (this.IsPublicFolderMailboxRestore)
     {
         dataObject.SkipFolderRules = true;
     }
     if (base.ParameterSetName.Equals("RemoteMailboxRestore"))
     {
         dataObject.RemoteDatabaseGuid = new Guid?(this.RemoteDatabaseGuid);
         dataObject.RemoteHostName     = this.RemoteHostName;
         dataObject.RemoteCredential   = RequestTaskHelper.GetNetworkCredential(this.RemoteCredential, new AuthenticationMethod?(AuthenticationMethod.WindowsIntegrated));
     }
 }
 private static void LoadAdditionalPropertiesFromUser(RequestJobBase requestJob)
 {
     if (requestJob.TargetUser != null)
     {
         requestJob.TargetAlias = requestJob.TargetUser.Alias;
         if (!requestJob.Flags.HasFlag(RequestFlags.TargetIsAggregatedMailbox))
         {
             requestJob.TargetExchangeGuid = requestJob.TargetUser.ExchangeGuid;
         }
         requestJob.TargetDatabase       = ADObjectIdResolutionHelper.ResolveDN(requestJob.TargetIsArchive ? requestJob.TargetUser.ArchiveDatabase : requestJob.TargetUser.Database);
         requestJob.RecipientTypeDetails = requestJob.TargetUser.RecipientTypeDetails;
         requestJob.TargetUserId         = requestJob.TargetUser.Id;
     }
 }
Beispiel #11
0
 private void ChooseTargetMailboxDatabase(TransactionalRequestJob dataObject)
 {
     if (this.targetContainer != null)
     {
         dataObject.TargetDatabase         = ADObjectIdResolutionHelper.ResolveDN(this.targetContainer.Database);
         dataObject.TargetContainerGuid    = this.targetContainer.MailboxContainerGuid;
         dataObject.TargetUnifiedMailboxId = this.targetContainer.GetCrossTenantObjectId();
     }
     else if (this.targetMailboxDatabase != null)
     {
         dataObject.TargetDatabase      = ADObjectIdResolutionHelper.ResolveDN(this.targetMailboxDatabase.Id);
         this.targetDatabaseInformation = new DatabaseInformation?(MapiUtils.FindServerForMdb(this.targetMailboxDatabase.Id.ObjectGuid, null, null, FindServerFlags.None));
     }
     dataObject.TargetVersion = this.targetDatabaseInformation.Value.ServerVersion;
 }
        protected override IConfigurable ConvertDataObjectToPresentationObject(IConfigurable dataObject)
        {
            if (dataObject == null)
            {
                return(null);
            }
            ADUser aduser = (ADUser)dataObject;

            if (null != aduser.MasterAccountSid)
            {
                aduser.LinkedMasterAccount = SecurityPrincipalIdParameter.GetFriendlyUserName(aduser.MasterAccountSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                aduser.ResetChangeTracking();
            }
            MailboxPlan mailboxPlan = new MailboxPlan(aduser);

            mailboxPlan.Database = ADObjectIdResolutionHelper.ResolveDN(mailboxPlan.Database);
            return(mailboxPlan);
        }
Beispiel #13
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         this.RJProvider.AttachToMDB(this.MdbId.ObjectGuid);
         this.InitializeMRSClient();
         TransactionalRequestJob dataObject = this.DataObject;
         dataObject.TimeTracker.SetTimestamp(RequestJobTimestamp.Creation, new DateTime?(DateTime.UtcNow));
         dataObject.TimeTracker.CurrentState = RequestState.Queued;
         dataObject.JobType             = MRSJobType.RequestJobE15_TenantHint;
         dataObject.RequestGuid         = Guid.NewGuid();
         dataObject.AllowedToFinishMove = true;
         dataObject.BatchName           = this.BatchName;
         dataObject.BadItemLimit        = this.BadItemLimit;
         dataObject.LargeItemLimit      = this.LargeItemLimit;
         dataObject.Status          = RequestStatus.Queued;
         dataObject.RequestJobState = JobProcessingState.Ready;
         dataObject.Identity        = new RequestJobObjectId(dataObject.RequestGuid, this.MdbId.ObjectGuid, null);
         dataObject.RequestQueue    = ADObjectIdResolutionHelper.ResolveDN(this.MdbId);
         dataObject.RequestCreator  = this.ExecutingUserIdentity;
         this.SetRequestProperties(dataObject);
         this.CreateIndexEntries(dataObject);
         dataObject.Suspend = this.Suspend;
         if (!string.IsNullOrEmpty(this.SuspendComment))
         {
             dataObject.Message = MrsStrings.MoveRequestMessageInformational(new LocalizedString(this.SuspendComment));
         }
         base.InternalValidate();
         if (this.MRSClient != null)
         {
             List <ReportEntry> entries = null;
             using (TransactionalRequestJob transactionalRequestJob = this.MRSClient.ValidateAndPopulateRequestJob(this.DataObject, out entries))
             {
                 this.CopyDataToDataObject(transactionalRequestJob);
                 RequestTaskHelper.WriteReportEntries(dataObject.Name, entries, dataObject.Identity, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
             }
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
        private static IList <SmtpSendConnectorConfig> GetEnabledSendConnectorsInSite(IConfigurationSession session, ADObjectId site, IList <SmtpSendConnectorConfig> sendConnectors)
        {
            IList <SmtpSendConnectorConfig> list = new List <SmtpSendConnectorConfig>();

            foreach (SmtpSendConnectorConfig smtpSendConnectorConfig in sendConnectors)
            {
                if (smtpSendConnectorConfig.Enabled)
                {
                    ADObjectId adobjectId = smtpSendConnectorConfig.HomeMtaServerId;
                    if (adobjectId == null && ADGlobalConfigSettings.SoftLinkEnabled)
                    {
                        adobjectId = ADGroup.GetServerIdFromHomeMta(ADObjectIdResolutionHelper.ResolveDN(smtpSendConnectorConfig.HomeMTA));
                    }
                    Server server = session.Read <Server>(adobjectId);
                    if (server != null && string.Equals(server.ServerSite.ToString(), site.ToString(), StringComparison.OrdinalIgnoreCase))
                    {
                        list.Add(smtpSendConnectorConfig);
                    }
                }
            }
            return(list);
        }
Beispiel #15
0
 protected override void SetRequestProperties(TransactionalRequestJob dataObject)
 {
     base.SetRequestProperties(dataObject);
     dataObject.RequestType  = MRSRequestType.MailboxRelocation;
     dataObject.JobType      = MRSJobType.RequestJobE15_AutoResume;
     dataObject.UserId       = this.mailbox.Id;
     dataObject.ExchangeGuid = this.mailbox.ExchangeGuid;
     RequestTaskHelper.ApplyOrganization(dataObject, this.mailbox.OrganizationId ?? OrganizationId.ForestWideOrgId);
     dataObject.UserOrgName       = ((this.mailbox.OrganizationId != null && this.mailbox.OrganizationId.OrganizationalUnit != null) ? this.mailbox.OrganizationId.OrganizationalUnit.Name : this.mailbox.Id.DomainId.ToString());
     dataObject.DistinguishedName = this.mailbox.DistinguishedName;
     dataObject.DisplayName       = this.mailbox.DisplayName;
     dataObject.Alias             = this.mailbox.Alias;
     dataObject.User = this.mailbox;
     dataObject.DomainControllerToUpdate = this.mailbox.OriginatingServer;
     dataObject.SourceDatabase           = ADObjectIdResolutionHelper.ResolveDN(this.mailbox.Database);
     dataObject.SourceVersion            = this.sourceDatabaseInformation.Value.ServerVersion;
     this.ChooseTargetMailboxDatabase(dataObject);
     dataObject.PreserveMailboxSignature = false;
     dataObject.IncrementalSyncInterval  = NewMailboxRelocationRequest.incrementalSyncInterval;
     dataObject.AllowLargeItems          = true;
     RequestTaskHelper.SetSkipMoving(this.SkipMoving, dataObject, new Task.TaskErrorLoggingDelegate(base.WriteError), true);
 }
        internal static int GetMailboxCount(ExchangeUpgradeBucket bucket)
        {
            int num = 0;
            List <ADObjectId> list = new List <ADObjectId>(bucket.Organizations.Count);

            foreach (ADObjectId adobjectId in bucket.Organizations)
            {
                int?mailboxCountFromCache = UpgradeBucketTaskHelper.MailboxCountCache.GetMailboxCountFromCache(adobjectId);
                if (mailboxCountFromCache != null)
                {
                    num += mailboxCountFromCache.Value;
                }
                else
                {
                    ADObjectIdResolutionHelper.ResolveDN(adobjectId);
                }
            }
            list.Sort((ADObjectId x, ADObjectId y) => x.PartitionGuid.CompareTo(y.PartitionGuid));
            ADObjectId adobjectId2 = null;
            ITenantConfigurationSession tenantConfigurationSession = null;

            foreach (ADObjectId adobjectId3 in list)
            {
                if (adobjectId2 == null || !adobjectId2.PartitionGuid.Equals(adobjectId3.PartitionGuid))
                {
                    tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsObjectId(adobjectId3), 59, "GetMailboxCount", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\UpgradeBucketTaskHelper.cs");
                }
                ExchangeConfigurationUnit exchangeConfigurationUnit = tenantConfigurationSession.Read <ExchangeConfigurationUnit>(adobjectId3);
                if (exchangeConfigurationUnit != null)
                {
                    int mailboxCount = UpgradeBucketTaskHelper.MailboxCountCache.GetMailboxCount(exchangeConfigurationUnit.OrganizationId, tenantConfigurationSession);
                    num += mailboxCount;
                }
                adobjectId2 = adobjectId3;
            }
            return(num);
        }
Beispiel #17
0
 protected override void SetRequestProperties(TransactionalRequestJob dataObject)
 {
     base.SetRequestProperties(dataObject);
     dataObject.RequestType = MRSRequestType.Merge;
     if (this.sourceUser != null)
     {
         dataObject.SourceUserId    = this.sourceUser.Id;
         dataObject.SourceUser      = this.sourceUser;
         dataObject.SourceIsArchive = this.SourceIsArchive;
         if (this.SourceIsArchive)
         {
             dataObject.SourceExchangeGuid = this.sourceUser.ArchiveGuid;
             dataObject.SourceDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.sourceUser.ArchiveDatabase);
         }
         else
         {
             dataObject.SourceExchangeGuid = this.sourceUser.ExchangeGuid;
             dataObject.SourceDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.sourceUser.Database);
         }
         dataObject.SourceAlias = this.sourceUser.Alias;
     }
     if (this.targetUser != null)
     {
         dataObject.TargetUserId    = this.targetUser.Id;
         dataObject.TargetUser      = this.targetUser;
         dataObject.TargetIsArchive = this.TargetIsArchive;
         if (this.TargetIsArchive)
         {
             dataObject.TargetExchangeGuid = this.targetUser.ArchiveGuid;
             dataObject.TargetDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.targetUser.ArchiveDatabase);
         }
         else
         {
             dataObject.TargetExchangeGuid = this.targetUser.ExchangeGuid;
             dataObject.TargetDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.targetUser.Database);
         }
         dataObject.TargetAlias = this.targetUser.Alias;
     }
     if (base.ParameterSetName.Equals("MigrationLocalMerge"))
     {
         if (!string.IsNullOrEmpty(this.SourceRootFolder))
         {
             dataObject.SourceRootFolder = this.SourceRootFolder;
         }
         if (!string.IsNullOrEmpty(this.TargetRootFolder))
         {
             dataObject.TargetRootFolder = this.TargetRootFolder;
         }
     }
     else
     {
         dataObject.IsAdministrativeCredential  = new bool?(this.IsAdministrativeCredential);
         dataObject.AuthenticationMethod        = new AuthenticationMethod?(this.AuthenticationMethod);
         dataObject.RemoteMailboxLegacyDN       = this.RemoteSourceMailboxLegacyDN;
         dataObject.RemoteUserLegacyDN          = this.RemoteSourceUserLegacyDN;
         dataObject.RemoteMailboxServerLegacyDN = this.RemoteSourceMailboxServerLegacyDN;
         dataObject.OutlookAnywhereHostName     = this.OutlookAnywhereHostName;
         dataObject.RemoteCredential            = RequestTaskHelper.GetNetworkCredential(this.RemoteCredential, new AuthenticationMethod?(this.AuthenticationMethod));
         dataObject.IncludeFolders               = this.IncludeListForIncrementalMerge;
         dataObject.ExcludeDumpster              = false;
         dataObject.ExcludeFolders               = null;
         dataObject.ContentFilter                = null;
         dataObject.ConflictResolutionOption     = new ConflictResolutionOption?(ConflictResolutionOption.KeepSourceItem);
         dataObject.AssociatedMessagesCopyOption = new FAICopyOption?(FAICopyOption.Copy);
     }
     dataObject.SuspendWhenReadyToComplete = this.SuspendWhenReadyToComplete;
     if (base.IsFieldSet("IncrementalSyncInterval"))
     {
         dataObject.IncrementalSyncInterval = this.IncrementalSyncInterval;
         dataObject.TimeTracker.SetTimestamp(RequestJobTimestamp.CompleteAfter, new DateTime?(DateTime.MaxValue));
         dataObject.JobType = MRSJobType.RequestJobE15_AutoResumeMerges;
     }
     if (this.SuspendWhenReadyToComplete || base.IsFieldSet("IncrementalSyncInterval"))
     {
         dataObject.IncludeFolders               = this.IncludeListForIncrementalMerge;
         dataObject.ExcludeDumpster              = false;
         dataObject.ExcludeFolders               = null;
         dataObject.ContentFilter                = null;
         dataObject.ConflictResolutionOption     = new ConflictResolutionOption?(ConflictResolutionOption.KeepSourceItem);
         dataObject.AssociatedMessagesCopyOption = new FAICopyOption?(FAICopyOption.Copy);
         dataObject.AllowedToFinishMove          = false;
     }
     if (base.IsFieldSet("StartAfter"))
     {
         RequestTaskHelper.SetStartAfter(new DateTime?(this.StartAfter), dataObject, null);
     }
 }
 protected override void SetRequestProperties(TransactionalRequestJob dataObject)
 {
     base.SetRequestProperties(dataObject);
     if (this.Eas)
     {
         dataObject.JobType = MRSJobType.RequestJobE15_SubType;
     }
     dataObject.RequestType = MRSRequestType.Sync;
     if (dataObject.WorkloadType == RequestWorkloadType.None)
     {
         dataObject.WorkloadType = RequestWorkloadType.SyncAggregation;
     }
     dataObject.RemoteHostName          = this.RemoteServerName;
     dataObject.RemoteHostPort          = this.RemoteServerPort;
     dataObject.SmtpServerName          = this.SmtpServerName;
     dataObject.SmtpServerPort          = this.SmtpServerPort;
     dataObject.EmailAddress            = this.RemoteEmailAddress;
     dataObject.AuthenticationMethod    = new AuthenticationMethod?(this.Authentication);
     dataObject.SecurityMechanism       = this.Security;
     dataObject.SyncProtocol            = this.syncProtocol;
     dataObject.IncrementalSyncInterval = this.IncrementalSyncInterval;
     if (this.Olc)
     {
         dataObject.AllowLargeItems = true;
         dataObject.UserPuid        = this.Puid;
         dataObject.OlcDGroup       = this.DGroup;
     }
     if (base.IsFieldSet("StartAfter"))
     {
         RequestTaskHelper.SetStartAfter(new DateTime?(this.StartAfter), dataObject, null);
     }
     else
     {
         RequestTaskHelper.SetStartAfter(new DateTime?(DateTime.MinValue), dataObject, null);
     }
     if (base.IsFieldSet("CompleteAfter"))
     {
         RequestTaskHelper.SetCompleteAfter(new DateTime?(this.CompleteAfter), dataObject, null);
     }
     else
     {
         dataObject.TimeTracker.SetTimestamp(RequestJobTimestamp.CompleteAfter, new DateTime?(DateTime.MaxValue));
     }
     if (string.IsNullOrEmpty(this.UserName))
     {
         this.UserName = this.RemoteEmailAddress.ToString();
     }
     if (!string.IsNullOrEmpty(this.TargetRootFolder))
     {
         dataObject.TargetRootFolder = this.TargetRootFolder;
     }
     dataObject.RemoteCredential = new NetworkCredential(this.UserName, this.Password);
     if (this.AggregatedMailboxGuid != Guid.Empty)
     {
         dataObject.Flags |= RequestFlags.TargetIsAggregatedMailbox;
     }
     if (this.targetUser != null)
     {
         dataObject.TargetUserId       = this.targetUser.Id;
         dataObject.TargetUser         = this.targetUser;
         dataObject.TargetExchangeGuid = ((this.AggregatedMailboxGuid != Guid.Empty) ? this.AggregatedMailboxGuid : this.targetUser.ExchangeGuid);
         dataObject.TargetDatabase     = ADObjectIdResolutionHelper.ResolveDN(this.targetUser.Database);
         dataObject.TargetAlias        = this.targetUser.Alias;
     }
 }
Beispiel #19
0
        private void ValidateSetParameters()
        {
            ADObjectId adobjectId = ADObjectIdResolutionHelper.ResolveDN(this.DataObject.DelegationTrustLink);

            if (adobjectId != null && (string.IsNullOrEmpty(adobjectId.DistinguishedName) || adobjectId.Parent.Equals(this.ConfigurationSession.DeletedObjectsContainer)))
            {
                adobjectId = null;
            }
            if (this.DelegationFederationTrust == null && this.AccountNamespace == null)
            {
                if (adobjectId == null)
                {
                    base.WriteError(new NoTrustConfiguredException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
                this.noTrustToUpdate = true;
                return;
            }
            if (this.DelegationFederationTrust != null)
            {
                if (this.AccountNamespace == null)
                {
                    if (adobjectId != null)
                    {
                        return;
                    }
                    base.WriteError(new NoAccountNamespaceException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
            }
            else
            {
                base.WriteError(new CannotSpecifyAccountNamespaceWithoutTrustException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            if (this.DataObject.AccountNamespace != null)
            {
                string x = FederatedOrganizationId.ContainsHybridConfigurationWellKnownSubDomain(this.DataObject.AccountNamespace.Domain) ? FederatedOrganizationId.AddHybridConfigurationWellKnownSubDomain(this.AccountNamespace.Domain) : this.AccountNamespace.Domain;
                if (!StringComparer.OrdinalIgnoreCase.Equals(x, this.DataObject.AccountNamespace.Domain) && adobjectId != null)
                {
                    base.WriteError(new TrustAlreadyDefinedException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
                if (adobjectId != null && !adobjectId.Equals(this.delegationTrustId))
                {
                    base.WriteError(new TrustAlreadyDefinedException(), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
            }
            ADObjectId adobjectId2 = this.matchedAcceptedDomain.FederatedOrganizationLink;

            if (adobjectId2 != null && adobjectId2.Parent.Equals(this.ConfigurationSession.DeletedObjectsContainer))
            {
                adobjectId2 = null;
            }
            if (adobjectId2 != null)
            {
                if (adobjectId2.ObjectGuid != this.DataObject.Id.ObjectGuid)
                {
                    base.WriteError(new DomainAlreadyFederatedException(this.AccountNamespace.Domain), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                }
                else
                {
                    this.noTrustToUpdate = true;
                }
            }
            TaskLogger.LogExit();
        }
Beispiel #20
0
        private FederatedOrganizationIdWithDomainStatus CreatePresentationObject(FederatedOrganizationId fedOrgId, bool includeExtendedDomainInfo)
        {
            FederatedOrganizationIdWithDomainStatus federatedOrganizationIdWithDomainStatus = new FederatedOrganizationIdWithDomainStatus(fedOrgId);

            if (fedOrgId.DelegationTrustLink == null)
            {
                return(federatedOrganizationIdWithDomainStatus);
            }
            FederationTrust federationTrust = this.ConfigurationSession.Read <FederationTrust>(fedOrgId.DelegationTrustLink);

            if (federationTrust == null)
            {
                fedOrgId.DelegationTrustLink = ADObjectIdResolutionHelper.ResolveDN(fedOrgId.DelegationTrustLink);
                ADSessionSettings             sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), OrganizationId.ForestWideOrgId, null, false);
                ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 147, "CreatePresentationObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Federation\\GetFederatedOrganizationIdentifier.cs");
                federationTrust = topologyConfigurationSession.Read <FederationTrust>(fedOrgId.DelegationTrustLink);
                if (federationTrust == null)
                {
                    return(federatedOrganizationIdWithDomainStatus);
                }
            }
            List <AcceptedDomain> allFederatedDomains = this.GetAllFederatedDomains(fedOrgId);

            if (allFederatedDomains.Count == 0)
            {
                return(federatedOrganizationIdWithDomainStatus);
            }
            foreach (AcceptedDomain acceptedDomain in allFederatedDomains)
            {
                if (acceptedDomain.IsDefaultFederatedDomain)
                {
                    federatedOrganizationIdWithDomainStatus.DefaultDomain = new SmtpDomain(acceptedDomain.DomainName.Domain);
                    break;
                }
            }
            MultiValuedProperty <FederatedDomain> multiValuedProperty = new MultiValuedProperty <FederatedDomain>();

            if (!includeExtendedDomainInfo)
            {
                foreach (AcceptedDomain acceptedDomain2 in allFederatedDomains)
                {
                    multiValuedProperty.Add(new FederatedDomain(new SmtpDomain(acceptedDomain2.DomainName.Domain)));
                }
                federatedOrganizationIdWithDomainStatus.Domains = multiValuedProperty;
                return(federatedOrganizationIdWithDomainStatus);
            }
            FederationProvision federationProvision = FederationProvision.Create(federationTrust, this);

            base.WriteVerbose(Strings.GetFedDomainStatusInfo(FederatedOrganizationId.AddHybridConfigurationWellKnownSubDomain(fedOrgId.AccountNamespace.Domain)));
            DomainState state = DomainState.Unknown;

            try
            {
                state = federationProvision.GetDomainState(FederatedOrganizationId.AddHybridConfigurationWellKnownSubDomain(fedOrgId.AccountNamespace.Domain));
            }
            catch (LocalizedException ex)
            {
                this.WriteError(new CannotGetDomainStatusFromPartnerSTSException(fedOrgId.AccountNamespace.ToString(), federationTrust.ApplicationIdentifier, ex.Message), ErrorCategory.ResourceUnavailable, null, false);
            }
            multiValuedProperty.Add(new FederatedDomain(fedOrgId.AccountNamespace, state));
            foreach (AcceptedDomain acceptedDomain3 in allFederatedDomains)
            {
                SmtpDomain smtpDomain = new SmtpDomain(acceptedDomain3.DomainName.Domain);
                if (!smtpDomain.Equals(fedOrgId.AccountNamespace))
                {
                    multiValuedProperty.Add(new FederatedDomain(smtpDomain));
                }
            }
            federatedOrganizationIdWithDomainStatus.Domains = multiValuedProperty;
            return(federatedOrganizationIdWithDomainStatus);
        }