コード例 #1
0
 public ActiveDirectoryUserProvider(bool useActiveDirectoryCache)
 {
     if (useActiveDirectoryCache)
     {
         this.directorySessionFactoryInstance = DirectorySessionFactory.GetInstance(DirectorySessionFactoryType.Cached);
         return;
     }
     this.directorySessionFactoryInstance = DirectorySessionFactory.GetInstance(DirectorySessionFactoryType.Default);
 }
コード例 #2
0
        internal static int GetMserveEntryTenantNegoConfig(string domainName)
        {
            IGlobalDirectorySession globalSession = DirectorySessionFactory.GetGlobalSession(null);
            bool flag;

            if (!globalSession.TryGetDomainFlag(domainName, GlsDomainFlags.Nego2Enabled, out flag))
            {
                return(-1);
            }
            if (!flag)
            {
                return(0);
            }
            return(1);
        }
コード例 #3
0
        private IGlobalDirectorySession GlobalDirectorySession(string redirectFormatForMServ = null)
        {
            switch (this.GlobalDirectoryService)
            {
            case GlobalDirectoryServiceType.Default:
                return(DirectorySessionFactory.GetGlobalSession(redirectFormatForMServ));

            case GlobalDirectoryServiceType.MServ:
                return(new MServDirectorySession(redirectFormatForMServ));

            case GlobalDirectoryServiceType.Gls:
                return(new GlsDirectorySession());

            default:
                throw new ArgumentException("GlobalDirectoryService");
            }
        }
コード例 #4
0
        internal static string GetRedirectServer(string redirectFormat, string address, int currentSiteId, int startRange, int endRange, bool overrideCurrentSiteCheck, bool throwExceptions)
        {
            string result;

            try
            {
                IGlobalDirectorySession globalSession = DirectorySessionFactory.GetGlobalSession(redirectFormat);
                result = globalSession.GetRedirectServer(address);
            }
            catch (MServTransientException)
            {
                if (throwExceptions)
                {
                    throw;
                }
                result = string.Empty;
            }
            catch (MServPermanentException)
            {
                if (throwExceptions)
                {
                    throw;
                }
                result = string.Empty;
            }
            catch (InvalidOperationException)
            {
                if (throwExceptions)
                {
                    throw;
                }
                result = string.Empty;
            }
            catch (TransientException)
            {
                if (throwExceptions)
                {
                    throw;
                }
                result = string.Empty;
            }
            return(result);
        }
コード例 #5
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (this.makeDefault && !this.DataObject.Default)
            {
                this.DataObject.Default = true;
                ADPagedReader <AcceptedDomain> adpagedReader = ((IConfigurationSession)base.DataSession).FindPaged <AcceptedDomain>(this.DataObject.Id.Parent, QueryScope.OneLevel, null, null, 0);
                foreach (AcceptedDomain acceptedDomain in adpagedReader)
                {
                    if (acceptedDomain.Default)
                    {
                        acceptedDomain.Default = false;
                        base.DataSession.Save(acceptedDomain);
                    }
                }
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.IsCoexistenceDomain) && this.DataObject.IsCoexistenceDomain != this.IsCoexistenceDomain)
            {
                if (!this.IsCoexistenceDomain)
                {
                    try
                    {
                        AcceptedDomainUtility.DeregisterCoexistenceDomain(this.DataObject.DomainName.Domain);
                        goto IL_162;
                    }
                    catch (TimeoutException exception)
                    {
                        base.WriteError(exception, ErrorCategory.InvalidArgument, null);
                        goto IL_162;
                    }
                    catch (InvalidOperationException exception2)
                    {
                        base.WriteError(exception2, ErrorCategory.InvalidArgument, null);
                        goto IL_162;
                    }
                    catch (SecurityAccessDeniedException exception3)
                    {
                        base.WriteError(exception3, ErrorCategory.InvalidArgument, null);
                        goto IL_162;
                    }
                    catch (CommunicationException exception4)
                    {
                        base.WriteError(exception4, ErrorCategory.InvalidArgument, null);
                        goto IL_162;
                    }
                }
                try
                {
                    AcceptedDomainUtility.RegisterCoexistenceDomain(this.DataObject.DomainName.Domain);
                }
                catch (TimeoutException exception5)
                {
                    base.WriteError(exception5, ErrorCategory.InvalidArgument, null);
                }
                catch (InvalidOperationException exception6)
                {
                    base.WriteError(exception6, ErrorCategory.InvalidArgument, null);
                }
                catch (SecurityAccessDeniedException exception7)
                {
                    base.WriteError(exception7, ErrorCategory.InvalidArgument, null);
                }
                catch (CommunicationException exception8)
                {
                    base.WriteError(exception8, ErrorCategory.InvalidArgument, null);
                }
IL_162:
                this.DataObject.IsCoexistenceDomain = this.IsCoexistenceDomain;
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.RawAuthenticationType))
            {
                this.DataObject.RawAuthenticationType = this.AuthenticationType;
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.InitialDomain))
            {
                this.DataObject.InitialDomain = this.InitialDomain;
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.RawLiveIdInstanceType))
            {
                this.DataObject.RawLiveIdInstanceType = this.LiveIdInstanceType;
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.EnableNego2Authentication))
            {
                this.DataObject.EnableNego2Authentication = this.EnableNego2Authentication;
                if (ManagementEndpointBase.IsGlobalDirectoryConfigured())
                {
                    IGlobalDirectorySession globalSession = DirectorySessionFactory.GetGlobalSession(null);
                    globalSession.SetDomainFlag(this.DataObject.Name, GlsDomainFlags.Nego2Enabled, this.EnableNego2Authentication);
                }
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.CatchAllRecipient))
            {
                if (this.resolvedCatchAllRecipient != null)
                {
                    this.DataObject.CatchAllRecipientID = this.resolvedCatchAllRecipient.OriginalId;
                }
                else
                {
                    this.DataObject.CatchAllRecipientID = null;
                }
            }
            if (base.Fields.IsModified(AcceptedDomainSchema.MatchSubDomains))
            {
                this.DataObject.MatchSubDomains = this.MatchSubDomains;
            }
            base.InternalProcessRecord();
            FfoDualWriter.SaveToFfo <AcceptedDomain>(this, this.DataObject, TenantSettingSyncLogType.SYNCACCEPTEDDOM, null);
            TaskLogger.LogExit();
        }
コード例 #6
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            this.DataObject.AutoCompletionEnabled  = this.AutoCompletionEnabled;
            this.DataObject.LargeTenantModeEnabled = this.LargeTenantModeEnabled;
            this.DataObject.SafeLockdownSchedule   = (this.SafeLockdownSchedule ?? Schedule.Always);
            if (base.Fields.IsModified(TenantRelocationRequestSchema.RelocationStateRequested))
            {
                this.DataObject.RelocationStateRequested = (RelocationStateRequested)this.RelocationStateRequested;
            }
            this.DataObject.TargetForest = this.targetAccountPartitionFqdn;
            this.sourceForestRIDMaster   = ForestTenantRelocationsCache.GetRidMasterName(this.sourceAccountPartitionId);
            DirectorySessionFactory @default = DirectorySessionFactory.Default;
            Fqdn domainController            = base.DomainController;
            ITenantConfigurationSession tenantConfigurationSession = @default.CreateTenantConfigurationSession((domainController != null) ? domainController : this.sourceForestRIDMaster, false, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAllTenantsPartitionId(this.sourceAccountPartitionId), 334, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\NewTenantRelocationRequest.cs");
            PartitionId partitionId = new PartitionId(this.targetAccountPartitionFqdn);

            this.targetForestRIDMaster = ForestTenantRelocationsCache.GetRidMasterName(partitionId);
            ITenantConfigurationSession tenantConfigurationSession2 = DirectorySessionFactory.Default.CreateTenantConfigurationSession(this.targetForestRIDMaster, false, ConsistencyMode.PartiallyConsistent, null, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 343, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\NewTenantRelocationRequest.cs");

            tenantConfigurationSession2.SessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
            MsoTenantCookieContainer msoTenantCookieContainer = tenantConfigurationSession2.GetMsoTenantCookieContainer(this.externalDirectoryOrganizationId);

            if (msoTenantCookieContainer != null && !NewTenantRelocationRequest.IntraForestRelocationEnabled())
            {
                InvalidOperationException exception = new InvalidOperationException(Strings.ErrorTargetPartitionHasTenantWithSameId(this.DataObject.DistinguishedName, this.targetAccountPartitionFqdn, msoTenantCookieContainer.DistinguishedName, this.DataObject.ExternalDirectoryOrganizationId));
                base.WriteError(exception, ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            string text = this.GetInitialDomainName(tenantConfigurationSession, this.DataObject.OrganizationId);
            ExchangeConfigurationUnit exchangeConfigurationUnitByName = tenantConfigurationSession2.GetExchangeConfigurationUnitByName(text);

            if (exchangeConfigurationUnitByName != null)
            {
                if (text.Length > 50)
                {
                    text = text.Substring(0, 50);
                }
                text = string.Format("{0}-RELO-{1}", text, Guid.NewGuid().ToString());
                if (text.Length > 64)
                {
                    text = text.Substring(0, 64);
                }
            }
            Exception      ex;
            OrganizationId targetSharedOrgId = SharedConfiguration.FindMostRecentSharedConfigurationInPartition(this.DataObject.OrganizationId, partitionId, out ex);

            if (ex != null)
            {
                base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            ADOrganizationalUnit adorganizationalUnit = null;
            bool useConfigNC = tenantConfigurationSession.UseConfigNC;

            try
            {
                tenantConfigurationSession.UseConfigNC = false;
                adorganizationalUnit = tenantConfigurationSession.Read <ADOrganizationalUnit>(this.DataObject.OrganizationId.OrganizationalUnit);
            }
            finally
            {
                tenantConfigurationSession.UseConfigNC = useConfigNC;
            }
            this.DataObject.RelocationStatusDetailsRaw = RelocationStatusDetails.InitializationStarted;
            base.InternalProcessRecord();
            ADObjectId enclosureContainerId = this.CreateEnclosureConfigContainer(text, tenantConfigurationSession2);
            ExchangeConfigurationUnit exchangeConfigurationUnit = this.CreateOrgConfigurationContainer(enclosureContainerId, targetSharedOrgId, this.DataObject.ExternalDirectoryOrganizationId, this.DataObject.ProgramId, this.DataObject.OfferId, this.DataObject.IsDehydrated, this.DataObject.IsStaticConfigurationShared, this.sourceForestFqdn, this.DataObject.Guid, this.DataObject.ExchangeObjectId, tenantConfigurationSession2);
            ADObjectId organizationalUnitLink = this.CreateOrganizationUnitContainer(text, adorganizationalUnit.Guid, adorganizationalUnit.ExchangeObjectId, tenantConfigurationSession2);

            exchangeConfigurationUnit.OrganizationalUnitLink     = organizationalUnitLink;
            exchangeConfigurationUnit.RelocationStatusDetailsRaw = RelocationStatusDetails.InitializationFinished;
            tenantConfigurationSession2.Save(exchangeConfigurationUnit);
            this.DataObject.RelocationStatusDetailsRaw = RelocationStatusDetails.InitializationFinished;
            base.DataSession.Save(this.DataObject);
            TenantRelocationRequest tenantRelocationRequest = (TenantRelocationRequest)base.DataSession.Read <TenantRelocationRequest>(this.DataObject.Identity);
            TenantRelocationRequest targetForestObject      = tenantConfigurationSession2.Read <TenantRelocationRequest>(exchangeConfigurationUnit.Id);

            TenantRelocationRequest.PopulatePresentationObject(tenantRelocationRequest, targetForestObject);
            GetTenantRelocationRequest.PopulateGlsProperty(tenantRelocationRequest, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
            GetTenantRelocationRequest.PopulateRidMasterProperties(tenantRelocationRequest, this.sourceForestRIDMaster, this.targetForestRIDMaster, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
            if (tenantRelocationRequest.OriginatingServer != this.sourceForestRIDMaster)
            {
                this.WriteWarning(Strings.WarningShouldWriteToRidMaster(tenantRelocationRequest.OriginatingServer, this.sourceForestRIDMaster));
            }
            base.WriteObject(tenantRelocationRequest);
            TaskLogger.LogExit();
        }