Example #1
0
 /// <summary>
 /// Return the session to the session manager
 /// </summary>
 public override void CleanUp()
 {
     if (Session != null && !string.IsNullOrEmpty(ComputerName))
     {
         CimConnectionManager.GetGlobalCimConnectionManager().ReleaseSession(ComputerName, Session);
         Session      = null;
         ComputerName = null;
     }
 }
Example #2
0
 /// <summary>
 /// Gets the global instance of the CIM session manager
 /// </summary>
 /// <returns></returns>
 public static CimConnectionManager GetGlobalCimConnectionManager()
 {
     lock (gcmLock)
     {
         if (_globalConnectionManagerInstance == null)
         {
             _globalConnectionManagerInstance = new CimConnectionManager();
         }
         return(_globalConnectionManagerInstance);
     }
 }
Example #3
0
        public static CimConnectionManager GetGlobalCimConnectionManager()
        {
            CimConnectionManager cimConnectionManager;

            lock (CimConnectionManager.gcmLock)
            {
                if (CimConnectionManager._globalConnectionManagerInstance == null)
                {
                    CimConnectionManager._globalConnectionManagerInstance = new CimConnectionManager();
                }
                cimConnectionManager = CimConnectionManager._globalConnectionManagerInstance;
            }
            return(cimConnectionManager);
        }
Example #4
0
        internal CimSession GetSession(string computerName, PSCredential credential, string certificateThumbprint, AuthenticationMechanism authenticationMechanism, CimSessionOptions sessionOptions, bool useSsl, uint port, PSSessionOption pssessionOption)
        {
            CimSession session;

            lock (this.SyncRoot)
            {
                if (this.availableSessions.ContainsKey(computerName))
                {
                    List <CimConnectionManager.SessionEntry> item = this.availableSessions[computerName];
                    if (item.Count > 0)
                    {
                        int num = 0;
                        while (num < item.Count)
                        {
                            CimConnectionManager.SessionEntry sessionEntry = item[num];
                            if ((sessionEntry.SessionOptions != null || sessionOptions != null) && !CimConnectionManager.CompareSessionOptions(sessionEntry, sessionOptions, credential, certificateThumbprint, authenticationMechanism, useSsl, port, pssessionOption))
                            {
                                num++;
                            }
                            else
                            {
                                sessionEntry.AddReference();
                                session = sessionEntry.Session;
                                return(session);
                            }
                        }
                    }
                }
                CimConnectionManager.SessionEntry sessionEntry1 = new CimConnectionManager.SessionEntry(computerName, credential, certificateThumbprint, authenticationMechanism, sessionOptions, useSsl, port, pssessionOption);
                sessionEntry1.IterationsRemaining = 6;
                sessionEntry1.AddReference();
                if (!this.availableSessions.ContainsKey(computerName))
                {
                    this.availableSessions.Add(computerName, new List <CimConnectionManager.SessionEntry>());
                }
                this.availableSessions[computerName].Add(sessionEntry1);
                session = sessionEntry1.Session;
            }
            return(session);
        }
 /// <summary>
 /// Gets the global instance of the CIM session manager
 /// </summary>
 /// <returns></returns>
 public static CimConnectionManager GetGlobalCimConnectionManager()
 {
     lock (gcmLock)
     {
         if (_globalConnectionManagerInstance == null)
         {
             _globalConnectionManagerInstance = new CimConnectionManager();
         }
         return _globalConnectionManagerInstance;
     }
 }
Example #6
0
		private static bool CompareSessionOptions(CimConnectionManager.SessionEntry sessionEntry, CimSessionOptions options2, PSCredential credential2, string certificateThumbprint, AuthenticationMechanism authenticationMechanism, bool useSsl, uint port, PSSessionOption pssessionOption)
		{
			TimeSpan timeout = sessionEntry.SessionOptions.Timeout;
			if (timeout.Equals(options2.Timeout))
			{
				if (string.Equals(sessionEntry.SessionOptions.Culture.ToString(), options2.Culture.ToString(), StringComparison.OrdinalIgnoreCase))
				{
					if (string.Equals(sessionEntry.SessionOptions.UICulture.ToString(), options2.UICulture.ToString(), StringComparison.OrdinalIgnoreCase))
					{
						if (string.Equals(sessionEntry.CertificateThumbprint, certificateThumbprint, StringComparison.OrdinalIgnoreCase))
						{
							if (sessionEntry.AuthenticationMechanism == authenticationMechanism)
							{
								if (WorkflowUtils.CompareCredential(sessionEntry.Credential, credential2))
								{
									if (sessionEntry.UseSsl == useSsl)
									{
										if (sessionEntry.Port == port)
										{
											if (!(pssessionOption == null ^ sessionEntry.PSSessionOption == null))
											{
												if (pssessionOption != null && sessionEntry.PSSessionOption != null)
												{
													if (sessionEntry.PSSessionOption.ProxyAccessType == pssessionOption.ProxyAccessType)
													{
														if (sessionEntry.PSSessionOption.ProxyAuthentication == pssessionOption.ProxyAuthentication)
														{
															if (WorkflowUtils.CompareCredential(sessionEntry.PSSessionOption.ProxyCredential, pssessionOption.ProxyCredential))
															{
																if (sessionEntry.PSSessionOption.SkipCACheck == pssessionOption.SkipCACheck)
																{
																	if (sessionEntry.PSSessionOption.SkipCNCheck == pssessionOption.SkipCNCheck)
																	{
																		if (sessionEntry.PSSessionOption.SkipRevocationCheck == pssessionOption.SkipRevocationCheck)
																		{
																			if (sessionEntry.PSSessionOption.NoEncryption == pssessionOption.NoEncryption)
																			{
																				if (sessionEntry.PSSessionOption.UseUTF16 != pssessionOption.UseUTF16)
																				{
																					return false;
																				}
																			}
																			else
																			{
																				return false;
																			}
																		}
																		else
																		{
																			return false;
																		}
																	}
																	else
																	{
																		return false;
																	}
																}
																else
																{
																	return false;
																}
															}
															else
															{
																return false;
															}
														}
														else
														{
															return false;
														}
													}
													else
													{
														return false;
													}
												}
												return true;
											}
											else
											{
												return false;
											}
										}
										else
										{
											return false;
										}
									}
									else
									{
										return false;
									}
								}
								else
								{
									return false;
								}
							}
							else
							{
								return false;
							}
						}
						else
						{
							return false;
						}
					}
					else
					{
						return false;
					}
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
Example #7
0
		public static CimConnectionManager GetGlobalCimConnectionManager()
		{
			CimConnectionManager cimConnectionManager;
			lock (CimConnectionManager.gcmLock)
			{
				if (CimConnectionManager._globalConnectionManagerInstance == null)
				{
					CimConnectionManager._globalConnectionManagerInstance = new CimConnectionManager();
				}
				cimConnectionManager = CimConnectionManager._globalConnectionManagerInstance;
			}
			return cimConnectionManager;
		}