示例#1
0
 public void AbandonPagedSearch(ref object pageCookie)
 {
     if (pageCookie != null)
     {
         this.Init();
         ADPageResultRequestControl aDPageResultRequestControl = new ADPageResultRequestControl();
         aDPageResultRequestControl.Cookie = pageCookie;
         ADSearchRequest aDSearchRequest = this.CreateSearchRequest(aDPageResultRequestControl);
         this._syncOps.AbandonSearch(this._sessionHandle, aDSearchRequest);
         pageCookie = null;
         return;
     }
     else
     {
         throw new ArgumentNullException("pageCookie");
     }
 }
示例#2
0
        public List <ADObject> PagedSearch(ref object pageCookie, out bool hasSizeLimitExceeded, int pageSize, int sizeLimit)
        {
            hasSizeLimitExceeded = false;
            Dictionary <string, ADObject> strs = null;
            HashSet <string> strs1             = null;
            HashSet <string> strs2             = null;
            int num = -2147483648;

            this.Init();
            if (this._searchRoot != null)
            {
                ADPageResultRequestControl aDPageResultRequestControl = new ADPageResultRequestControl(pageSize);
                if (pageCookie != null)
                {
                    aDPageResultRequestControl.Cookie = pageCookie;
                }
                ADSearchRequest aDSearchRequest = this.CreateSearchRequest(aDPageResultRequestControl);
                aDSearchRequest.SizeLimit = sizeLimit;
                ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);
                this.ProcessResponseControls(aDSearchResponse);
                if (aDSearchResponse.ResultCode == ResultCode.SizeLimitExceeded)
                {
                    hasSizeLimitExceeded = true;
                }
                List <ADObject> aDObjects = new List <ADObject>(aDSearchResponse.Entries.Count);
                if (this._autoRangeRetrieve)
                {
                    strs  = new Dictionary <string, ADObject>(StringComparer.OrdinalIgnoreCase);
                    strs1 = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                    strs2 = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                }
                foreach (ADObject entry in aDSearchResponse.Entries)
                {
                    ADObject aDObject = this.CreateRichADObject(entry);
                    aDObjects.Add(aDObject);
                    if (!this._autoRangeRetrieve)
                    {
                        continue;
                    }
                    if (!string.IsNullOrEmpty(aDObject.DistinguishedName))
                    {
                        strs.Add(aDObject.DistinguishedName, aDObject);
                        ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject, aDObject, strs1, strs2, ref num);
                    }
                }
                while (this._autoRangeRetrieve && strs2.Count > 0 && strs1.Count > 0 && num != -2147483648)
                {
                    using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._adSession.SessionInfo))
                    {
                        IEnumerable <ADObject> aDObjects1 = ADObjectSearcher.FetchRemainingRangeRetrievalAttributeValues(aDObjectSearcher, this, strs1, strs2, num);
                        strs1.Clear();
                        strs2.Clear();
                        num = -2147483648;
                        foreach (ADObject aDObject1 in aDObjects1)
                        {
                            ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject1, strs[aDObject1.DistinguishedName], strs1, strs2, ref num);
                        }
                    }
                }
                pageCookie = null;
                DirectoryControl[] controls = aDSearchResponse.Controls;
                int num1 = 0;
                while (num1 < (int)controls.Length)
                {
                    if (controls[num1] as ADPageResultResponseControl == null)
                    {
                        num1++;
                    }
                    else
                    {
                        pageCookie = ((ADPageResultResponseControl)controls[num1]).Cookie;
                        break;
                    }
                }
                return(aDObjects);
            }
            else
            {
                DebugLogger.LogWarning("ADObjectSearcher", "PagedSearch: SearchRoot is null");
                throw new ArgumentNullException("SearchRoot");
            }
        }
示例#3
0
        private ADSearchRequest CreateSearchRequest(ADPageResultRequestControl pageControl)
        {
            if (this._autoRangeRetrieve)
            {
                if (string.IsNullOrEmpty(this._attributeScopedQuery))
                {
                    foreach (string str in this._propertyList)
                    {
                        if (str.IndexOf(";range=", StringComparison.OrdinalIgnoreCase) <= 0)
                        {
                            continue;
                        }
                        throw new ArgumentException(str);
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            bool            flag            = true;
            ADSearchRequest aDSearchRequest = new ADSearchRequest(this._searchRoot, this._filter.GetLdapFilterString(), (SearchScope)this._searchScope, this._propertyList.ToArray());

            aDSearchRequest.TypesOnly = this._propertyNamesOnly;
            aDSearchRequest.TimeLimit = this._timeLimit;
            aDSearchRequest.SizeLimit = this._sizeLimit;
            if (pageControl == null)
            {
                pageControl = new ADPageResultRequestControl(this._pageSize);
            }
            aDSearchRequest.Controls.Add(pageControl);
            if (this._searchOption.HasValue)
            {
                aDSearchRequest.Controls.Add(new SearchOptionsControl(this._searchOption.Value));
            }
            if (this._showDeleted)
            {
                aDSearchRequest.Controls.Add(new ShowDeletedControl());
            }
            if (this._showDeactivatedLink)
            {
                aDSearchRequest.Controls.Add(new ADShowDeactivatedLinkControl());
            }
            if (this._suppressServerRangeRetrievalError)
            {
                aDSearchRequest.Controls.Add(new ADSupressRangeRetrievalErrorControl());
            }
            if (this._sdFlags != SecurityMasks.None)
            {
                aDSearchRequest.Controls.Add(new SecurityDescriptorFlagControl(this._sdFlags));
            }
            if (this._attributeScopedQuery != null)
            {
                aDSearchRequest.Controls.Add(new AsqRequestControl(this._attributeScopedQuery));
                flag = false;
            }
            if (this._quotaQuerySid != null)
            {
                aDSearchRequest.Controls.Add(new QuotaControl(this._quotaQuerySid));
            }
            if (this._inputDN != null)
            {
                aDSearchRequest.Controls.Add(new ADInputDNControl(this._inputDN));
            }
            aDSearchRequest.ObjectScopedControls = flag;
            return(aDSearchRequest);
        }
示例#4
0
		public List<ADObject> PagedSearch(ref object pageCookie, out bool hasSizeLimitExceeded, int pageSize, int sizeLimit)
		{
			hasSizeLimitExceeded = false;
			Dictionary<string, ADObject> strs = null;
			HashSet<string> strs1 = null;
			HashSet<string> strs2 = null;
			int num = -2147483648;
			this.Init();
			if (this._searchRoot != null)
			{
				ADPageResultRequestControl aDPageResultRequestControl = new ADPageResultRequestControl(pageSize);
				if (pageCookie != null)
				{
					aDPageResultRequestControl.Cookie = pageCookie;
				}
				ADSearchRequest aDSearchRequest = this.CreateSearchRequest(aDPageResultRequestControl);
				aDSearchRequest.SizeLimit = sizeLimit;
				ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);
				this.ProcessResponseControls(aDSearchResponse);
				if (aDSearchResponse.ResultCode == ResultCode.SizeLimitExceeded)
				{
					hasSizeLimitExceeded = true;
				}
				List<ADObject> aDObjects = new List<ADObject>(aDSearchResponse.Entries.Count);
				if (this._autoRangeRetrieve)
				{
					strs = new Dictionary<string, ADObject>(StringComparer.OrdinalIgnoreCase);
					strs1 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
					strs2 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
				}
				foreach (ADObject entry in aDSearchResponse.Entries)
				{
					ADObject aDObject = this.CreateRichADObject(entry);
					aDObjects.Add(aDObject);
					if (!this._autoRangeRetrieve)
					{
						continue;
					}
					if (!string.IsNullOrEmpty (aDObject.DistinguishedName))
					{
						strs.Add(aDObject.DistinguishedName, aDObject);
						ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject, aDObject, strs1, strs2, ref num);
					}
				}
				while (this._autoRangeRetrieve && strs2.Count > 0 && strs1.Count > 0 && num != -2147483648)
				{
					using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._adSession.SessionInfo))
					{
						IEnumerable<ADObject> aDObjects1 = ADObjectSearcher.FetchRemainingRangeRetrievalAttributeValues(aDObjectSearcher, this, strs1, strs2, num);
						strs1.Clear();
						strs2.Clear();
						num = -2147483648;
						foreach (ADObject aDObject1 in aDObjects1)
						{
							ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject1, strs[aDObject1.DistinguishedName], strs1, strs2, ref num);
						}
					}
				}
				pageCookie = null;
				DirectoryControl[] controls = aDSearchResponse.Controls;
				int num1 = 0;
				while (num1 < (int)controls.Length)
				{
					if (controls[num1] as ADPageResultResponseControl == null)
					{
						num1++;
					}
					else
					{
						pageCookie = ((ADPageResultResponseControl)controls[num1]).Cookie;
						break;
					}
				}
				return aDObjects;
			}
			else
			{
				DebugLogger.LogWarning("ADObjectSearcher", "PagedSearch: SearchRoot is null");
				throw new ArgumentNullException("SearchRoot");
			}
		}
示例#5
0
		private ADSearchRequest CreateSearchRequest(ADPageResultRequestControl pageControl)
		{
			if (this._autoRangeRetrieve)
			{
				if (string.IsNullOrEmpty(this._attributeScopedQuery))
				{
					foreach (string str in this._propertyList)
					{
						if (str.IndexOf(";range=", StringComparison.OrdinalIgnoreCase) <= 0)
						{
							continue;
						}
						throw new ArgumentException(str);
					}
				}
				else
				{
					throw new NotSupportedException();
				}
			}
			bool flag = true;
			ADSearchRequest aDSearchRequest = new ADSearchRequest(this._searchRoot, this._filter.GetLdapFilterString(), (SearchScope)this._searchScope, this._propertyList.ToArray());
			aDSearchRequest.TypesOnly = this._propertyNamesOnly;
			aDSearchRequest.TimeLimit = this._timeLimit;
			aDSearchRequest.SizeLimit = this._sizeLimit;
			if (pageControl == null)
			{
				pageControl = new ADPageResultRequestControl(this._pageSize);
			}
			aDSearchRequest.Controls.Add(pageControl);
			if (this._searchOption.HasValue)
			{
				aDSearchRequest.Controls.Add(new SearchOptionsControl(this._searchOption.Value));
			}
			if (this._showDeleted)
			{
				aDSearchRequest.Controls.Add(new ShowDeletedControl());
			}
			if (this._showDeactivatedLink)
			{
				aDSearchRequest.Controls.Add(new ADShowDeactivatedLinkControl());
			}
			if (this._suppressServerRangeRetrievalError)
			{
				aDSearchRequest.Controls.Add(new ADSupressRangeRetrievalErrorControl());
			}
			if (this._sdFlags != SecurityMasks.None)
			{
				aDSearchRequest.Controls.Add(new SecurityDescriptorFlagControl(this._sdFlags));
			}
			if (this._attributeScopedQuery != null)
			{
				aDSearchRequest.Controls.Add(new AsqRequestControl(this._attributeScopedQuery));
				flag = false;
			}
			if (this._quotaQuerySid != null)
			{
				aDSearchRequest.Controls.Add(new QuotaControl(this._quotaQuerySid));
			}
			if (this._inputDN != null)
			{
				aDSearchRequest.Controls.Add(new ADInputDNControl(this._inputDN));
			}
			aDSearchRequest.ObjectScopedControls = flag;
			return aDSearchRequest;
		}
示例#6
0
		public void AbandonPagedSearch(ref object pageCookie)
		{
			if (pageCookie != null)
			{
				this.Init();
				ADPageResultRequestControl aDPageResultRequestControl = new ADPageResultRequestControl();
				aDPageResultRequestControl.Cookie = pageCookie;
				ADSearchRequest aDSearchRequest = this.CreateSearchRequest(aDPageResultRequestControl);
				this._syncOps.AbandonSearch(this._sessionHandle, aDSearchRequest);
				pageCookie = null;
				return;
			}
			else
			{
				throw new ArgumentNullException("pageCookie");
			}
		}