Esempio n. 1
0
 protected override void InternalBeginProcessing()
 {
     base.InternalBeginProcessing();
     this.rootOrgSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 168, "InternalBeginProcessing", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\DirectorySetup\\SetupTaskBase.cs");
     if (ADSessionSettings.GetProcessServerSettings() != null && this.Organization == null)
     {
         this.PrepareSessionsForRootOrg();
         return;
     }
     this.PrepareSessionsForTenant();
 }
Esempio n. 2
0
        private void InitializeRunspaceServerSettings(object sender, EventArgs e)
        {
            ISessionState    sessionState     = this.CurrentTaskContext.SessionState;
            ADServerSettings adserverSettings = null;
            bool             flag             = false;
            bool             flag2            = false;
            string           value            = null;

            if (sessionState != null)
            {
                flag2 = ExchangePropertyContainer.IsContainerInitialized(sessionState);
                if (flag2)
                {
                    adserverSettings = ExchangePropertyContainer.GetServerSettings(sessionState);
                    if (adserverSettings != null)
                    {
                        value = "SessionState";
                    }
                }
            }
            if (adserverSettings == null)
            {
                adserverSettings = ADSessionSettings.GetProcessServerSettings();
                if (adserverSettings != null)
                {
                    value = "ProcessServerSettings";
                }
            }
            if (adserverSettings == null)
            {
                if (this.CurrentTaskContext.CommandShell != null)
                {
                    this.CurrentTaskContext.CommandShell.TryGetVariableValue <ADServerSettings>(ExchangePropertyContainer.ADServerSettingsVarName, out adserverSettings);
                }
                flag = (adserverSettings != null);
                if (adserverSettings != null)
                {
                    value = "CommandShell";
                }
            }
            if (TopologyProvider.CurrentTopologyMode == TopologyMode.ADTopologyService)
            {
                ADServerSettings cmdletADServerSettings = this.GetCmdletADServerSettings();
                if (cmdletADServerSettings != null)
                {
                    this.CurrentTaskContext.Items["CmdletServerSettings"] = cmdletADServerSettings;
                    value            = "ADTopologyService";
                    adserverSettings = cmdletADServerSettings;
                }
            }
            if (adserverSettings == null)
            {
                flag = true;
                if (TopologyProvider.CurrentTopologyMode == TopologyMode.Adam)
                {
                    if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn)
                    {
                        this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsAdam);
                    }
                    if (Globals.InstanceType == InstanceType.NotInitialized)
                    {
                        Globals.InitializeSinglePerfCounterInstance();
                    }
                    value            = "Adam-SimpleServerSettings";
                    adserverSettings = new SimpleServerSettings();
                }
                else if (TopologyProvider.CurrentTopologyMode == TopologyMode.Ldap)
                {
                    if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.CommandShell != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn)
                    {
                        this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsLocal);
                    }
                    Globals.InitializeMultiPerfCounterInstance("EMS");
                    value            = "Ldap-LocalCmdLineServerSettings";
                    adserverSettings = LocalCmdLineServerSettings.CreateLocalCmdLineServerSettings();
                }
                else
                {
                    if (this.CurrentTaskContext.InvocationInfo != null && this.CurrentTaskContext.InvocationInfo.IsVerboseOn)
                    {
                        this.CurrentTaskContext.CommandShell.WriteVerbose(Strings.VerboseInitializeRunspaceServerSettingsRemote);
                    }
                    adserverSettings = this.CreateADServerSettingsForOrganization(false);
                    if (adserverSettings == null)
                    {
                        value            = "GCRandomly";
                        adserverSettings = RunspaceServerSettings.CreateRunspaceServerSettings(false);
                    }
                }
            }
            if (flag)
            {
                if (flag2)
                {
                    ExchangePropertyContainer.SetServerSettings(sessionState, adserverSettings);
                }
                else
                {
                    sessionState.Variables[ExchangePropertyContainer.ADServerSettingsVarName] = adserverSettings;
                }
            }
            ADSessionSettings.SetThreadADContext(new ADDriverContext(adserverSettings, ContextMode.Cmdlet));
            LocalizedString localizedString = LocalizedString.Empty;

            if (this.CurrentTaskContext.InvocationInfo != null)
            {
                localizedString = TaskVerboseStringHelper.GetADServerSettings(this.CurrentTaskContext.InvocationInfo.CommandName, adserverSettings);
                if (this.CurrentTaskContext.InvocationInfo.IsVerboseOn && !string.Equals(this.CurrentTaskContext.InvocationInfo.CommandName, "Write-ExchangeSetupLog", StringComparison.OrdinalIgnoreCase) && this.CurrentTaskContext.CommandShell != null)
                {
                    this.CurrentTaskContext.CommandShell.WriteVerbose(localizedString);
                }
            }
            CmdletLogger.SafeSetLogger(this.CurrentTaskContext.UniqueId, RpsCmdletMetadata.RunspaceSettingsCreationHint, value);
            CmdletLogHelper.LogADServerSettings(this.CurrentTaskContext.UniqueId, adserverSettings);
            if (ExTraceGlobals.LogTracer.IsTraceEnabled(TraceType.InfoTrace))
            {
                ExTraceGlobals.LogTracer.Information <LocalizedString>(0L, "Cmdlet ADServerSettings {0}", localizedString);
            }
        }
Esempio n. 3
0
        public IEnumerable <T> GetObjects <T>(ObjectId rootId, IConfigDataProvider session, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where T : IConfigurable, new()
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (!(session is IDirectorySession))
            {
                throw new ArgumentException("Session should be an IDirectorySession", "session");
            }
            if (rootId != null && !(rootId is ADObjectId))
            {
                throw new ArgumentException("RootId must be an ADObjectId", "rootId");
            }
            IDirectorySession directorySession  = (IDirectorySession)session;
            IDirectorySession directorySession2 = null;

            if (!(this is OrganizationIdParameter) && VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && rootId == null && ADSessionSettings.GetProcessServerSettings() == null && directorySession is IConfigurationSession)
            {
                IConfigurationSession configurationSession   = directorySession as IConfigurationSession;
                ADObjectId            configurationUnitsRoot = directorySession.GetConfigurationUnitsRoot();
                bool flag = !string.IsNullOrEmpty(this.rawIdentity) && this.rawIdentity.IndexOf("\\") != -1;
                if (this.InternalADObjectId != null)
                {
                    flag = !string.IsNullOrEmpty(this.InternalADObjectId.DistinguishedName);
                }
                if (!flag && configurationSession.UseConfigNC && !configurationUnitsRoot.IsDescendantOf(directorySession.GetConfigurationNamingContext()) && typeof(ADConfigurationObject).IsAssignableFrom(typeof(T)) && !typeof(ADNonExchangeObject).IsAssignableFrom(typeof(T)))
                {
                    T                    t        = (default(T) == null) ? Activator.CreateInstance <T>() : default(T);
                    ADObject             adobject = t as ADObject;
                    ObjectScopeAttribute objectScopeAttribute;
                    bool                 flag2 = adobject.IsApplicableToTenant(out objectScopeAttribute);
                    if (directorySession.SessionSettings.ExecutingUserOrganizationId.Equals(OrganizationId.ForestWideOrgId) && directorySession.SessionSettings.CurrentOrganizationId.Equals(directorySession.SessionSettings.ExecutingUserOrganizationId) && flag2)
                    {
                        directorySession2 = directorySession;
                    }
                }
            }
            if (directorySession2 == null)
            {
                directorySession2 = ADSession.RescopeSessionToTenantSubTree(directorySession);
            }
            return(this.GetObjects <T>((ADObjectId)rootId, directorySession, directorySession2, optionalData, out notFoundReason));
        }