Пример #1
0
 private void InitSchemaUtil(ADSessionInfo sessionInfo)
 {
     if (this._sessionInfo != null && this._schemaUtil == null)
     {
         this._schemaUtil = new ADSchemaUtil(sessionInfo);
     }
 }
Пример #2
0
        public static bool MatchConnectionState(ADSessionInfo info1, ADSessionInfo info2, bool ignoreLocatorFlags)
        {
            bool     valueOrDefault;
            TimeSpan?timeout  = info1.Timeout;
            TimeSpan?nullable = info2.Timeout;

            if (timeout.HasValue != nullable.HasValue)
            {
                valueOrDefault = false;
            }
            else
            {
                if (!timeout.HasValue)
                {
                    valueOrDefault = true;
                }
                else
                {
                    valueOrDefault = timeout.GetValueOrDefault() == nullable.GetValueOrDefault();
                }
            }
            if (!valueOrDefault || info1.AuthType != info2.AuthType)
            {
                return(false);
            }
            else
            {
                return(ADSessionOptions.MatchConnectionState(info1.Options, info2.Options, ignoreLocatorFlags));
            }
        }
Пример #3
0
        private static ADForestPartitionInfo GetForestPartitionInfo(ADSessionInfo sessionInfo)
        {
            ADForestPartitionInfo forestPartitionInfo;

            using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
            {
                forestPartitionInfo = ADForestPartitionInfo.GetForestPartitionInfo(aDObjectSearcher.GetRootDSE());
            }
            return(forestPartitionInfo);
        }
Пример #4
0
 private bool AreCredentialsExplicit(ADSessionInfo info)
 {
     if (info == null)
     {
         return(false);
     }
     else
     {
         return(ADPasswordUtils.AreCredentialsExplicit(info.Credential));
     }
 }
Пример #5
0
		private bool AreCredentialsExplicit(ADSessionInfo info)
		{
			if (info == null)
			{
				return false;
			}
			else
			{
				return ADPasswordUtils.AreCredentialsExplicit(info.Credential);
			}
		}
Пример #6
0
		internal static ADObjectSearcher BuildSearcher(ADSessionInfo session, string searchRoot, ADSearchScope searchScope, bool showDeleted)
		{
			ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(session);
			aDObjectSearcher.PageSize = 0x100;
			aDObjectSearcher.SearchRoot = searchRoot;
			aDObjectSearcher.Scope = searchScope;
			if (showDeleted)
			{
				aDObjectSearcher.ShowDeleted = true;
				aDObjectSearcher.ShowDeactivatedLink = true;
			}
			return aDObjectSearcher;
		}
Пример #7
0
 internal bool MatchConnectionOptions(ADSessionInfo info)
 {
     if (info.ServerNameOnly != null)
     {
         IADSession aDSession = this._storeAccess as IADSession;
         string     option    = (string)aDSession.GetOption(this._handle, 48);
         if (info.ServerNameOnly.Equals(option, StringComparison.OrdinalIgnoreCase) && info.EffectivePortNumber == this.SessionInfo.EffectivePortNumber)
         {
             return(ADSessionInfo.MatchConnectionState(this._info, info, true));
         }
     }
     return(ADSessionInfo.MatchConnectionState(this._info, info, false));
 }
Пример #8
0
 private void Refresh(ADRootDSE rootDSE)
 {
     if (rootDSE != null)
     {
         if (rootDSE.SessionInfo != null)
         {
             if (this._forestId.Equals(rootDSE.SubSchemaSubEntry, StringComparison.OrdinalIgnoreCase))
             {
                 object[] objArray = new object[1];
                 objArray[0] = this._forestId;
                 DebugLogger.LogInfo("ADForestPartitionInfo", "Refreshing PartitionList of Forest: {0}", objArray);
                 List <string> strs        = new List <string>();
                 ADSessionInfo sessionInfo = rootDSE.SessionInfo;
                 if (rootDSE.ServerType == ADServerType.ADDS && sessionInfo.ConnectedToGC)
                 {
                     sessionInfo = sessionInfo.Copy();
                     sessionInfo.SetEffectivePort(LdapConstants.LDAP_PORT);
                 }
                 using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
                 {
                     aDObjectSearcher.SchemaTranslation = false;
                     aDObjectSearcher.SearchRoot        = string.Concat("CN=Partitions,", rootDSE.ConfigurationNamingContext);
                     aDObjectSearcher.Properties.Add("nCName");
                     aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "crossRef");
                     foreach (ADObject aDObject in aDObjectSearcher.FindAll())
                     {
                         if (aDObject["nCName"] == null || aDObject["nCName"].Count <= 0)
                         {
                             continue;
                         }
                         strs.Add((string)aDObject["nCName"][0]);
                     }
                     this._forestPartitionList = new ReadOnlyCollection <string>(strs);
                 }
                 return;
             }
             else
             {
                 throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ForestIdDoesNotMatch, new object[0]));
             }
         }
         else
         {
             throw new ArgumentNullException("rootDSE.SessionInfo");
         }
     }
     else
     {
         throw new ArgumentNullException("rootDSE");
     }
 }
Пример #9
0
		public void DeleteEntry(ADSessionInfo info)
		{
			string str = this.GenerateKey(info);
			DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("DeleteEntry: removing entry ", str, " from sessioncache"));
			int num = 0;
			if (this.FindEntryInServerList(str, info, out num) != null)
			{
				ADSessionCache._sessionMap[str].RemoveAt(num);
				if (ADSessionCache._sessionMap[str].Count == 0)
				{
					ADSessionCache._sessionMap.Remove(str);
				}
			}
		}
Пример #10
0
 public ADActiveObject(ADSessionInfo sessionInfo, ADObject obj)
 {
     this._sdFlags = SecurityMasks.Dacl;
     if (obj != null)
     {
         this._adSession = ADSession.ConstructSession(sessionInfo);
         this._adObject  = obj;
         return;
     }
     else
     {
         DebugLogger.LogWarning("ADActiveObject", "Constructor(ADSessionInfo,ADObject) called with null obj");
         throw new ArgumentNullException("obj");
     }
 }
Пример #11
0
        private string GenerateKey(ADSessionInfo info)
        {
            string serverNameOnly = ADSessionCache._defaultServerKey;
            int    lDAPPORT       = LdapConstants.LDAP_PORT;

            if (info != null)
            {
                if (!string.IsNullOrEmpty(info.ServerNameOnly))
                {
                    serverNameOnly = info.ServerNameOnly;
                }
                lDAPPORT = info.EffectivePortNumber;
            }
            return(string.Concat(serverNameOnly, ":", lDAPPORT));
        }
Пример #12
0
		public ADActiveObject(ADSessionInfo sessionInfo, ADObject obj)
		{
			this._sdFlags = SecurityMasks.Dacl;
			if (obj != null)
			{
				this._adSession = ADSession.ConstructSession(sessionInfo);
				this._adObject = obj;
				return;
			}
			else
			{
				DebugLogger.LogWarning("ADActiveObject", "Constructor(ADSessionInfo,ADObject) called with null obj");
				throw new ArgumentNullException("obj");
			}
		}
Пример #13
0
        public void DeleteEntry(ADSessionInfo info)
        {
            string str = this.GenerateKey(info);

            DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("DeleteEntry: removing entry ", str, " from sessioncache"));
            int num = 0;

            if (this.FindEntryInServerList(str, info, out num) != null)
            {
                ADSessionCache._sessionMap[str].RemoveAt(num);
                if (ADSessionCache._sessionMap[str].Count == 0)
                {
                    ADSessionCache._sessionMap.Remove(str);
                }
            }
        }
Пример #14
0
        public bool GetEntry(ADSessionInfo info, out ADSession session)
        {
            DebugLogger.LogInfo(ADSessionCache._debugCategory, "GetEntry: Entering");
            string str = this.GenerateKey(info);
            int    num = 0;

            if (ADSessionCache._sessionMap.ContainsKey(str))
            {
                ADSessionCache.CacheEntry cacheEntry = this.FindEntryInServerList(str, info, out num);
                if (cacheEntry != null)
                {
                    session = cacheEntry.Session;
                    return(true);
                }
            }
            session = null;
            return(false);
        }
Пример #15
0
		public static ADSession ConstructSession(ADSessionInfo info)
		{
			ADSession aDSession = null;
			if (info == null)
			{
				info = new ADSessionInfo();
			}
			lock (ADSession._sessionCache)
			{
				if (!ADSession._sessionCache.GetEntry(info, out aDSession))
				{
					aDSession = new ADSession(info);
					ADSession._sessionCache.AddEntry(aDSession._info, aDSession);
				}
				aDSession.AddRef();
			}
			aDSession.Create();
			return aDSession;
		}
Пример #16
0
		internal static string GetCurrentDriveLocation(SessionState sessionState, ADSessionInfo sessionInfo)
		{
			string str = null;
			ADDriveInfo current = sessionState.Drive.Current as ADDriveInfo;
			if (current != null)
			{
				string currentLocation = current.CurrentLocation;
				str = ADPathModule.MakePath(current.RootWithoutAbsolutePathToken, currentLocation, current.FormatType);
				if (current.FormatType == ADPathFormat.Canonical && str != string.Empty)
				{
					if (sessionInfo.Server != null)
					{
						//TODO: Review sessionInfo.Server;
					}
					str = ADPathModule.ConvertPath(sessionInfo, str, ADPathFormat.Canonical, ADPathFormat.X500);
				}
			}
			return str;
		}
Пример #17
0
        public static ADSession ConstructSession(ADSessionInfo info)
        {
            ADSession aDSession = null;

            if (info == null)
            {
                info = new ADSessionInfo();
            }
            lock (ADSession._sessionCache)
            {
                if (!ADSession._sessionCache.GetEntry(info, out aDSession))
                {
                    aDSession = new ADSession(info);
                    ADSession._sessionCache.AddEntry(aDSession._info, aDSession);
                }
                aDSession.AddRef();
            }
            aDSession.Create();
            return(aDSession);
        }
Пример #18
0
		public static string ConvertPath(ADSessionInfo sessionInfo, string path, ADPathFormat fromFormat, ADPathFormat toFormat)
		{
			string str;
			if (fromFormat != toFormat)
			{
				if (fromFormat == ADPathFormat.Canonical && !string.IsNullOrEmpty(path) && CanonicalPath.IndexOfFirstDelimiter(path) == -1)
				{
					path = string.Concat(path, "/");
				}
				using (ADAccountManagement aDAccountManagement = new ADAccountManagement(sessionInfo))
				{
					str = aDAccountManagement.TranslateName(path, fromFormat, toFormat);
				}
				return str;
			}
			else
			{
				return path;
			}
		}
Пример #19
0
        public ADSessionInfo Copy()
        {
            ADSessionInfo aDSessionInfo = new ADSessionInfo(this._server);

            aDSessionInfo._fullyQualifiedDnsHostName = this._fullyQualifiedDnsHostName;
            aDSessionInfo._connectionless            = this._connectionless;
            aDSessionInfo._defaultPortNumber         = this._defaultPortNumber;
            aDSessionInfo._timeout        = this._timeout;
            aDSessionInfo._authType       = this._authType;
            aDSessionInfo._appendedPort   = this._appendedPort;
            aDSessionInfo._serverNameOnly = this._serverNameOnly;
            if (this._credential != null)
            {
                aDSessionInfo._credential = new PSCredential(this._credential.UserName, this._credential.Password.Copy());
            }
            if (this._options != null)
            {
                aDSessionInfo._options = this._options.Copy();
            }
            return(aDSessionInfo);
        }
Пример #20
0
        public void AddEntry(ADSessionInfo info, ADSession session)
        {
            PSCredential credential;
            string       str = this.GenerateKey(info);

            DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("AddEntry: Adding Entry , Key: ", str));
            ADSessionCache.CacheEntry cacheEntry = new ADSessionCache.CacheEntry();
            cacheEntry.Session = session;
            ADSessionCache.CacheEntry cacheEntry1 = cacheEntry;
            if (info == null)
            {
                credential = null;
            }
            else
            {
                credential = info.Credential;
            }
            cacheEntry1.Credential = credential;
            if (!this.AreCredentialsExplicit(info))
            {
                WindowsIdentity current = WindowsIdentity.GetCurrent(true);
                if (current != null)
                {
                    cacheEntry.ImpersonatedOwnerSid = current.Owner;
                }
            }
            if (!ADSessionCache._sessionMap.ContainsKey(str))
            {
                ADSessionCache._sessionMap.Add(str, new List <ADSessionCache.CacheEntry>(1));
                ADSessionCache._sessionMap[str].Add(cacheEntry);
                return;
            }
            else
            {
                ADSessionCache._sessionMap[str].Add(cacheEntry);
                return;
            }
        }
Пример #21
0
		public void AddEntry(ADSessionInfo info, ADSession session)
		{
			PSCredential credential;
			string str = this.GenerateKey(info);
			DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("AddEntry: Adding Entry , Key: ", str));
			ADSessionCache.CacheEntry cacheEntry = new ADSessionCache.CacheEntry();
			cacheEntry.Session = session;
			ADSessionCache.CacheEntry cacheEntry1 = cacheEntry;
			if (info == null)
			{
				credential = null;
			}
			else
			{
				credential = info.Credential;
			}
			cacheEntry1.Credential = credential;
			if (!this.AreCredentialsExplicit(info))
			{
				WindowsIdentity current = WindowsIdentity.GetCurrent(true);
				if (current != null)
				{
					cacheEntry.ImpersonatedOwnerSid = current.Owner;
				}
			}
			if (!ADSessionCache._sessionMap.ContainsKey(str))
			{
				ADSessionCache._sessionMap.Add(str, new List<ADSessionCache.CacheEntry>(1));
				ADSessionCache._sessionMap[str].Add(cacheEntry);
				return;
			}
			else
			{
				ADSessionCache._sessionMap[str].Add(cacheEntry);
				return;
			}
		}
Пример #22
0
 public ADObjectSearcher(ADSessionInfo sessionInfo, ADObject obj)
 {
     this._searchScope              = ADSearchScope.Subtree;
     this._filter                   = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
     this._propertyList             = new List <string>(ADObject.DefaultProperties);
     this._timeLimit                = TimeSpan.Zero;
     this._schemaTranslationEnabled = true;
     this._pageSize                 = 0x100;
     this._searchOption             = null;
     this._autoRangeRetrieve        = true;
     this._sdFlags                  = SecurityMasks.Owner | SecurityMasks.Group | SecurityMasks.Dacl;
     if (sessionInfo == null)
     {
         if (obj == null)
         {
             this._adSession = ADSession.ConstructSession(null);
         }
         else
         {
             this._adSession = ADSession.ConstructSession(obj.SessionInfo);
         }
     }
     else
     {
         this._adSession = ADSession.ConstructSession(sessionInfo);
     }
     if (obj != null)
     {
         this._adObject   = obj;
         this._searchRoot = this._adObject.DistinguishedName;
         foreach (string propertyName in this._adObject.PropertyNames)
         {
             this._propertyList.Add(propertyName);
         }
     }
 }
Пример #23
0
        private ADSessionCache.CacheEntry FindEntryInServerList(string key, ADSessionInfo info, out int index)
        {
            List <ADSessionCache.CacheEntry> cacheEntries = null;

            ADSessionCache.CacheEntry item = null;
            int num;

            index = -1;
            if (ADSessionCache._sessionMap.TryGetValue(key, out cacheEntries))
            {
                if (DebugLogger.Level >= DebugLogLevel.Info)
                {
                    object[] count = new object[4];
                    count[0] = "FindEntryInServerList: Found ";
                    count[1] = cacheEntries.Count;
                    count[2] = " session(s) in cache with key: ";
                    count[3] = key;
                    DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat(count));
                }
                bool            flag    = this.AreCredentialsExplicit(info);
                WindowsIdentity current = null;
                if (!flag)
                {
                    current = WindowsIdentity.GetCurrent(true);
                }
                int  i     = 0;
                bool flag1 = false;
                for (i = 0; i < cacheEntries.Count; i++)
                {
                    item = cacheEntries[i];
                    if (item.Session.MatchConnectionOptions(info))
                    {
                        bool flag2 = ADPasswordUtils.AreCredentialsExplicit(item.Credential);
                        if (!flag || !flag2)
                        {
                            if (!flag && !flag2)
                            {
                                if (current != null || !(null == item.ImpersonatedOwnerSid))
                                {
                                    if (current.Owner == item.ImpersonatedOwnerSid)
                                    {
                                        flag1 = true;
                                        break;
                                    }
                                }
                                else
                                {
                                    flag1 = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            if (ADPasswordUtils.MatchCredentials(item.Credential, info.Credential))
                            {
                                flag1 = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (DebugLogger.Level >= DebugLogLevel.Info)
                        {
                            DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList: Connection options did NOT match with session ", item.Session.SessionInfo.Server));
                        }
                    }
                }
                if (!flag1)
                {
                    if (DebugLogger.Level >= DebugLogLevel.Info)
                    {
                        DebugLogger.LogInfo(ADSessionCache._debugCategory, "FindEntryInServerList. Could NOT find a matching cached session entry");
                    }
                }
                else
                {
                    if (DebugLogger.Level >= DebugLogLevel.Info)
                    {
                        DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList. Found a cached session entry: ", item.Session.SessionInfo.Server));
                    }
                }
                int numPointer = index;
                if (flag1)
                {
                    num = i;
                }
                else
                {
                    num = -1;
                }
                numPointer = num;
                if (flag1)
                {
                    return(item);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                if (DebugLogger.Level >= DebugLogLevel.Info)
                {
                    DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList: Could NOT find a session in cache with key: ", key));
                }
                return(null);
            }
        }
Пример #24
0
		private string GenerateKey(ADSessionInfo info)
		{
			string serverNameOnly = ADSessionCache._defaultServerKey;
			int lDAPPORT = LdapConstants.LDAP_PORT;
			if (info != null)
			{
				if (!string.IsNullOrEmpty(info.ServerNameOnly))
				{
					serverNameOnly = info.ServerNameOnly;
				}
				lDAPPORT = info.EffectivePortNumber;
			}
			return string.Concat(serverNameOnly, ":", lDAPPORT);
		}
Пример #25
0
 public ADDynamicSession(ADSessionInfo info) : base(info)
 {
 }
Пример #26
0
 public ADSchema(ADSessionInfo sessionInfo)
 {
     this._sessionInfo = sessionInfo.Copy();
     this.Init();
 }
Пример #27
0
		internal bool MatchConnectionOptions(ADSessionInfo info)
		{
			if (info.ServerNameOnly != null)
			{
				IADSession aDSession = this._storeAccess as IADSession;
				string option = (string)aDSession.GetOption(this._handle, 48);
				if (info.ServerNameOnly.Equals(option, StringComparison.OrdinalIgnoreCase) && info.EffectivePortNumber == this.SessionInfo.EffectivePortNumber)
				{
					return ADSessionInfo.MatchConnectionState(this._info, info, true);
				}
			}
			return ADSessionInfo.MatchConnectionState(this._info, info, false);
		}
Пример #28
0
		ADSessionHandle Microsoft.ActiveDirectory.Management.IADSession.Create(ADSessionInfo info)
		{
			AdwsConnection adwsConnection = new AdwsConnection(info);
			return new ADSessionHandle(adwsConnection);
		}
Пример #29
0
		internal ADSchemaUtil(ADSessionInfo sessionInfo)
		{
			this._sessionInfo = sessionInfo;
			this.Init();
		}
Пример #30
0
		private bool ValidateDynamicParameters(string path, ADProviderCommonParameters parameters, ADSessionInfo sessionInfo)
		{
			bool flag;
			if (parameters != null)
			{
				try
				{
					parameters.ValidateParameters();
					goto Label0;
				}
				catch (ArgumentException argumentException1)
				{
					ArgumentException argumentException = argumentException1;
					base.WriteError(ADUtilities.GetErrorRecord(argumentException, "ADProvider:ValidateDynamicParameters:InvalidArgument", path));
					this.Trace(DebugLogLevel.Error, "Leaving ValidateDynamicParameters: ArgumentException: InvalidArgument");
					flag = false;
				}
				return flag;
			}
			return true;
		Label0:
			if (this.GetHostType(parameters, this.ExtendedDriveInfo) == ADPathHostType.GC)
			{
				ADRootDSE rootDSE = this.GetRootDSE(sessionInfo);
				if (rootDSE.ServerType != ADServerType.ADLDS)
				{
					if (sessionInfo.EffectivePortNumber != LdapConstants.LDAP_GC_PORT && sessionInfo.EffectivePortNumber != LdapConstants.LDAP_SSL_GC_PORT)
					{
						base.WriteError(ADUtilities.GetErrorRecord(new ArgumentException(StringResources.ADProviderGCInvalidWithAppendedPort), "ADProvider:ValidateDynamicParameters:GC with appened server port which is not equal to the GC port ", path));
						this.Trace(DebugLogLevel.Error, "Leaving ValidateDynamicParameters: ArgumentException: GC with appened server port which is not equal to the GC port ");
						return false;
					}
					else
					{
						return true;
					}
				}
				else
				{
					base.WriteError(ADUtilities.GetErrorRecord(new ArgumentException(StringResources.ADProviderGCInvalidForADLDS), "ADProvider:ValidateDynamicParameters:GC with ADLDS", path));
					this.Trace(DebugLogLevel.Error, "Leaving ValidateDynamicParameters: ArgumentException: GC with ADLDS");
					return false;
				}
			}
			else
			{
				return true;
			}
		}
Пример #31
0
		private ADSessionCache.CacheEntry FindEntryInServerList(string key, ADSessionInfo info, out int index)
		{
			List<ADSessionCache.CacheEntry> cacheEntries = null;
			ADSessionCache.CacheEntry item = null;
			int num;
			index = -1;
			if (ADSessionCache._sessionMap.TryGetValue(key, out cacheEntries))
			{
				if (DebugLogger.Level >= DebugLogLevel.Info)
				{
					object[] count = new object[4];
					count[0] = "FindEntryInServerList: Found ";
					count[1] = cacheEntries.Count;
					count[2] = " session(s) in cache with key: ";
					count[3] = key;
					DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat(count));
				}
				bool flag = this.AreCredentialsExplicit(info);
				WindowsIdentity current = null;
				if (!flag)
				{
					current = WindowsIdentity.GetCurrent(true);
				}
				int i = 0;
				bool flag1 = false;
				for (i = 0; i < cacheEntries.Count; i++)
				{
					item = cacheEntries[i];
					if (item.Session.MatchConnectionOptions(info))
					{
						bool flag2 = ADPasswordUtils.AreCredentialsExplicit(item.Credential);
						if (!flag || !flag2)
						{
							if (!flag && !flag2)
							{
								if (current != null || !(null == item.ImpersonatedOwnerSid))
								{
									if (current.Owner == item.ImpersonatedOwnerSid)
									{
										flag1 = true;
										break;
									}
								}
								else
								{
									flag1 = true;
									break;
								}
							}
						}
						else
						{
							if (ADPasswordUtils.MatchCredentials(item.Credential, info.Credential))
							{
								flag1 = true;
								break;
							}
						}
					}
					else
					{
						if (DebugLogger.Level >= DebugLogLevel.Info)
						{
							DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList: Connection options did NOT match with session ", item.Session.SessionInfo.Server));
						}
					}
				}
				if (!flag1)
				{
					if (DebugLogger.Level >= DebugLogLevel.Info)
					{
						DebugLogger.LogInfo(ADSessionCache._debugCategory, "FindEntryInServerList. Could NOT find a matching cached session entry");
					}
				}
				else
				{
					if (DebugLogger.Level >= DebugLogLevel.Info)
					{
						DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList. Found a cached session entry: ", item.Session.SessionInfo.Server));
					}
				}
				int numPointer = index;
				if (flag1)
				{
					num = i;
				}
				else
				{
					num = -1;
				}
				numPointer = num;
				if (flag1)
				{
					return item;
				}
				else
				{
					return null;
				}
			}
			else
			{
				if (DebugLogger.Level >= DebugLogLevel.Info)
				{
					DebugLogger.LogInfo(ADSessionCache._debugCategory, string.Concat("FindEntryInServerList: Could NOT find a session in cache with key: ", key));
				}
				return null;
			}
		}
Пример #32
0
		private void WriteADObject(ADObject adObj, ADSessionInfo sessionInfo, ADProviderCommonParameters parameters, ADDriveInfo extendedDriveInfo)
		{
			adObj.SessionInfo = sessionInfo;
			if (this.GetFormatType(parameters, extendedDriveInfo) != ADPathFormat.Canonical)
			{
				this.WriteItemObjectWithAbsolutePath(this.WrapADObjectInPSObject(adObj, parameters, extendedDriveInfo), adObj.DistinguishedName, true);
				return;
			}
			else
			{
				if (!adObj.Contains("canonicalName"))
				{
					base.WriteError(ADUtilities.GetErrorRecord(new ADException(string.Format(StringResources.ADProviderUnableToReadProperty, "canonicalName", adObj.DistinguishedName)), "ADProvider:WriteADObject:UnableToReadCanonicalName", adObj.DistinguishedName));
					this.Trace(DebugLogLevel.Error, string.Format("Leaving WriteADObject: Unable to read canonical name for object {0}.", adObj.DistinguishedName));
					return;
				}
				else
				{
					this.WriteItemObjectWithAbsolutePath(this.WrapADObjectInPSObject(adObj, parameters, extendedDriveInfo), (string)adObj["canonicalName"].Value, true);
					return;
				}
			}
		}
Пример #33
0
		private void WriteADRootDSE(ADRootDSE rootDse, ADSessionInfo sessionInfo)
		{
			rootDse.SessionInfo = sessionInfo;
			rootDse.SessionInfo.ServerType = rootDse.ServerType;
			this.WriteItemObjectWithAbsolutePath(rootDse, "", true);
		}
Пример #34
0
		public bool GetEntry(ADSessionInfo info, out ADSession session)
		{
			DebugLogger.LogInfo(ADSessionCache._debugCategory, "GetEntry: Entering");
			string str = this.GenerateKey(info);
			int num = 0;
			if (ADSessionCache._sessionMap.ContainsKey(str))
			{
				ADSessionCache.CacheEntry cacheEntry = this.FindEntryInServerList(str, info, out num);
				if (cacheEntry != null)
				{
					session = cacheEntry.Session;
					return true;
				}
			}
			session = null;
			return false;
		}
Пример #35
0
		public SafeSessionCache(ADSessionInfo info)
		{
			this._session = ADSession.ConstructSession(info);
		}
Пример #36
0
		private ADRootDSE GetRootDSE(ADSessionInfo sessionInfo, ICollection<string> propertiesToRetrieve)
		{
			ADRootDSE rootDSE;
			this.Trace(DebugLogLevel.Verbose, "Entering GetRootDSE");
			ADObjectSearcher aDObjectSearcher = this.BuildADObjectSearcher(sessionInfo);
			using (aDObjectSearcher)
			{
				rootDSE = aDObjectSearcher.GetRootDSE(propertiesToRetrieve);
			}
			this.Trace(DebugLogLevel.Verbose, "Leaving GetRootDSE");
			return rootDSE;
		}
Пример #37
0
 internal ADTopologyManagement(ADSessionInfo sessionInfo)
 {
     this._adSession = ADSession.ConstructSession(sessionInfo);
 }
Пример #38
0
		public CmdletSessionInfo(ADSessionInfo adSessionInfo, ADRootDSE adRootDse, string defaultQueryPath, string defaultPartitionPath, string defaultCreationPath, ADServerType connectedADServerType, IADCmdletCache cmdletSessionCache, IADCmdletMessageWriter cmdletMessageWriter, PSCmdlet psCmdlet, ADParameterSet cmdletParameters)
		{
			this._adSessionInfo = adSessionInfo;
			this._adRootDse = adRootDse;
			this._defaultQueryPath = defaultQueryPath;
			this._defaultPartitionPath = defaultPartitionPath;
			this._defaultCreationPath = defaultCreationPath;
			this._connectedADServerType = connectedADServerType;
			this._cmdletSessionCache = cmdletSessionCache;
			this._cmdletMessageWriter = cmdletMessageWriter;
			this._psCmdlet = psCmdlet;
			this._cmdletParameters = cmdletParameters;
		}
Пример #39
0
		public ADTypeConverter(ADSessionInfo sessionInfo)
		{
			this._sessionInfo = sessionInfo;
		}
Пример #40
0
		private static ADForestPartitionInfo GetForestPartitionInfo(ADSessionInfo sessionInfo)
		{
			ADForestPartitionInfo forestPartitionInfo;
			using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
			{
				forestPartitionInfo = ADForestPartitionInfo.GetForestPartitionInfo(aDObjectSearcher.GetRootDSE());
			}
			return forestPartitionInfo;
		}
Пример #41
0
		internal ADAccountManagement(ADSessionInfo sessionInfo)
		{
			this._adSession = ADSession.ConstructSession(sessionInfo);
		}
Пример #42
0
		protected ADSession(ADSessionInfo info)
		{
			this._handleLock = new object();
			this._info = info.Copy();
			this._storeAccess = ADServiceStoreAccessFactory.GetObject();
		}
Пример #43
0
 internal ADSchemaUtil(ADSessionInfo sessionInfo)
 {
     this._sessionInfo = sessionInfo;
     this.Init();
 }
Пример #44
0
		private void InitSchemaUtil(ADSessionInfo sessionInfo)
		{
			if (this._sessionInfo != null && this._schemaUtil == null)
			{
				this._schemaUtil = new ADSchemaUtil(sessionInfo);
			}
		}
Пример #45
0
 public ADTypeConverter(ADSessionInfo sessionInfo)
 {
     this._sessionInfo = sessionInfo;
 }
        public ADSessionHandle Create(ADSessionInfo info)
        {
            ADDirectoryServiceConnection adwsConnection = new ADDirectoryServiceConnection(info);

            return(new ADSessionHandle(adwsConnection));
        }
Пример #47
0
		private ADRootDSE GetRootDSE(ADSessionInfo sessionInfo)
		{
			return this.GetRootDSE(sessionInfo, null);
		}
        ADSessionHandle Microsoft.ActiveDirectory.Management.IADSession.Create(ADSessionInfo info)
        {
            ADDirectoryServiceConnection adwsConnection = new ADDirectoryServiceConnection(info);

            return(new ADSessionHandle(adwsConnection));
        }
Пример #49
0
		public ADObjectSearcher(ADSessionInfo sessionInfo) : this(sessionInfo, null)
		{
		}
Пример #50
0
 protected ADSession(ADSessionInfo info)
 {
     this._handleLock  = new object();
     this._info        = info.Copy();
     this._storeAccess = ADServiceStoreAccessFactory.GetObject();
 }
Пример #51
0
		public ADObjectSearcher(ADSessionInfo sessionInfo, ADObject obj)
		{
			this._searchScope = ADSearchScope.Subtree;
			this._filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
			this._propertyList = new List<string>(ADObject.DefaultProperties);
			this._timeLimit = TimeSpan.Zero;
			this._schemaTranslationEnabled = true;
			this._pageSize = 0x100;
			this._searchOption = null;
			this._autoRangeRetrieve = true;
			this._sdFlags = SecurityMasks.Owner | SecurityMasks.Group | SecurityMasks.Dacl;
			if (sessionInfo == null)
			{
				if (obj == null)
				{
					this._adSession = ADSession.ConstructSession(null);
				}
				else
				{
					this._adSession = ADSession.ConstructSession(obj.SessionInfo);
				}
			}
			else
			{
				this._adSession = ADSession.ConstructSession(sessionInfo);
			}
			if (obj != null)
			{
				this._adObject = obj;
				this._searchRoot = this._adObject.DistinguishedName;
				foreach (string propertyName in this._adObject.PropertyNames)
				{
					this._propertyList.Add(propertyName);
				}
			}
		}
Пример #52
0
 public ADObjectSearcher(ADSessionInfo sessionInfo) : this(sessionInfo, null)
 {
 }
Пример #53
0
 internal ADAccountManagement(ADSessionInfo sessionInfo)
 {
     this._adSession = ADSession.ConstructSession(sessionInfo);
 }
Пример #54
0
		internal ADTopologyManagement(ADSessionInfo sessionInfo)
		{
			this._adSession = ADSession.ConstructSession(sessionInfo);
		}
Пример #55
0
		private ADObjectSearcher BuildADObjectSearcher(ADSessionInfo sessionInfo)
		{
			ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo);
			aDObjectSearcher.PageSize = ADProviderDefaults.InternalProviderSearchPageSize;
			return aDObjectSearcher;
		}