Exemple #1
0
 private void InitSchemaUtil(ADSessionInfo sessionInfo)
 {
     if (this._sessionInfo != null && this._schemaUtil == null)
     {
         this._schemaUtil = new ADSchemaUtil(sessionInfo);
     }
 }
Exemple #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));
            }
        }
        private static ADForestPartitionInfo GetForestPartitionInfo(ADSessionInfo sessionInfo)
        {
            ADForestPartitionInfo forestPartitionInfo;

            using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
            {
                forestPartitionInfo = ADForestPartitionInfo.GetForestPartitionInfo(aDObjectSearcher.GetRootDSE());
            }
            return(forestPartitionInfo);
        }
Exemple #4
0
 private bool AreCredentialsExplicit(ADSessionInfo info)
 {
     if (info == null)
     {
         return(false);
     }
     else
     {
         return(ADPasswordUtils.AreCredentialsExplicit(info.Credential));
     }
 }
Exemple #5
0
		private bool AreCredentialsExplicit(ADSessionInfo info)
		{
			if (info == null)
			{
				return false;
			}
			else
			{
				return ADPasswordUtils.AreCredentialsExplicit(info.Credential);
			}
		}
Exemple #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;
		}
Exemple #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));
 }
 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");
     }
 }
Exemple #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);
				}
			}
		}
Exemple #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");
     }
 }
Exemple #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));
        }
Exemple #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");
			}
		}
Exemple #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);
                }
            }
        }
Exemple #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);
        }
Exemple #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;
		}
Exemple #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;
		}
Exemple #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);
        }
Exemple #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;
			}
		}
Exemple #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);
        }
Exemple #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;
            }
        }
Exemple #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;
			}
		}
 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);
         }
     }
 }
Exemple #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);
            }
        }
Exemple #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);
		}
 public ADDynamicSession(ADSessionInfo info) : base(info)
 {
 }
Exemple #26
0
 public ADSchema(ADSessionInfo sessionInfo)
 {
     this._sessionInfo = sessionInfo.Copy();
     this.Init();
 }
Exemple #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);
		}
		ADSessionHandle Microsoft.ActiveDirectory.Management.IADSession.Create(ADSessionInfo info)
		{
			AdwsConnection adwsConnection = new AdwsConnection(info);
			return new ADSessionHandle(adwsConnection);
		}
Exemple #29
0
		internal ADSchemaUtil(ADSessionInfo sessionInfo)
		{
			this._sessionInfo = sessionInfo;
			this.Init();
		}
Exemple #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;
			}
		}
Exemple #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;
			}
		}
Exemple #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;
				}
			}
		}
Exemple #33
0
		private void WriteADRootDSE(ADRootDSE rootDse, ADSessionInfo sessionInfo)
		{
			rootDse.SessionInfo = sessionInfo;
			rootDse.SessionInfo.ServerType = rootDse.ServerType;
			this.WriteItemObjectWithAbsolutePath(rootDse, "", true);
		}
Exemple #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;
		}
Exemple #35
0
		public SafeSessionCache(ADSessionInfo info)
		{
			this._session = ADSession.ConstructSession(info);
		}
Exemple #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;
		}
 internal ADTopologyManagement(ADSessionInfo sessionInfo)
 {
     this._adSession = ADSession.ConstructSession(sessionInfo);
 }
Exemple #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;
		}
Exemple #39
0
		public ADTypeConverter(ADSessionInfo sessionInfo)
		{
			this._sessionInfo = sessionInfo;
		}
		private static ADForestPartitionInfo GetForestPartitionInfo(ADSessionInfo sessionInfo)
		{
			ADForestPartitionInfo forestPartitionInfo;
			using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
			{
				forestPartitionInfo = ADForestPartitionInfo.GetForestPartitionInfo(aDObjectSearcher.GetRootDSE());
			}
			return forestPartitionInfo;
		}
Exemple #41
0
		internal ADAccountManagement(ADSessionInfo sessionInfo)
		{
			this._adSession = ADSession.ConstructSession(sessionInfo);
		}
Exemple #42
0
		protected ADSession(ADSessionInfo info)
		{
			this._handleLock = new object();
			this._info = info.Copy();
			this._storeAccess = ADServiceStoreAccessFactory.GetObject();
		}
Exemple #43
0
 internal ADSchemaUtil(ADSessionInfo sessionInfo)
 {
     this._sessionInfo = sessionInfo;
     this.Init();
 }
Exemple #44
0
		private void InitSchemaUtil(ADSessionInfo sessionInfo)
		{
			if (this._sessionInfo != null && this._schemaUtil == null)
			{
				this._schemaUtil = new ADSchemaUtil(sessionInfo);
			}
		}
Exemple #45
0
 public ADTypeConverter(ADSessionInfo sessionInfo)
 {
     this._sessionInfo = sessionInfo;
 }
        public ADSessionHandle Create(ADSessionInfo info)
        {
            ADDirectoryServiceConnection adwsConnection = new ADDirectoryServiceConnection(info);

            return(new ADSessionHandle(adwsConnection));
        }
Exemple #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));
        }
Exemple #49
0
		public ADObjectSearcher(ADSessionInfo sessionInfo) : this(sessionInfo, null)
		{
		}
Exemple #50
0
 protected ADSession(ADSessionInfo info)
 {
     this._handleLock  = new object();
     this._info        = info.Copy();
     this._storeAccess = ADServiceStoreAccessFactory.GetObject();
 }
Exemple #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);
				}
			}
		}
 public ADObjectSearcher(ADSessionInfo sessionInfo) : this(sessionInfo, null)
 {
 }
 internal ADAccountManagement(ADSessionInfo sessionInfo)
 {
     this._adSession = ADSession.ConstructSession(sessionInfo);
 }
Exemple #54
0
		internal ADTopologyManagement(ADSessionInfo sessionInfo)
		{
			this._adSession = ADSession.ConstructSession(sessionInfo);
		}
Exemple #55
0
		private ADObjectSearcher BuildADObjectSearcher(ADSessionInfo sessionInfo)
		{
			ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo);
			aDObjectSearcher.PageSize = ADProviderDefaults.InternalProviderSearchPageSize;
			return aDObjectSearcher;
		}