示例#1
0
        public ADRootDSE GetRootDSE()
        {
            this.Init();
            ADRootDSE rootDSE = this._adSession.RootDSE;

            if (rootDSE == null)
            {
                string[] strArrays = new string[2];
                strArrays[0] = "*";
                strArrays[1] = "msDS-PortLDAP";
                ADSearchRequest aDSearchRequest = new ADSearchRequest("", ADObjectSearcher.DefaultSearchFilter.GetLdapFilterString(), SearchScope.Base, strArrays);
                aDSearchRequest.TimeLimit = this._timeLimit;
                ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);
                if (aDSearchResponse.Entries.Count > 0)
                {
                    rootDSE = new ADRootDSE();
                    ADObject item = aDSearchResponse.Entries[0];
                    foreach (string propertyName in item.PropertyNames)
                    {
                        rootDSE.Add(propertyName, item[propertyName]);
                    }
                    this._adSession.RootDSE = rootDSE;
                }
                return(rootDSE);
            }
            else
            {
                return(rootDSE);
            }
        }
示例#2
0
        public ADRootDSE GetRootDSE(ICollection <string> propertyList, bool propertyNamesOnly)
        {
            this.Init();
            ADRootDSE aDRootDSE = null;

            string[] strArrays = null;
            if (propertyList != null)
            {
                strArrays = new string[propertyList.Count];
                propertyList.CopyTo(strArrays, 0);
            }
            ADSearchRequest aDSearchRequest = new ADSearchRequest("", ADObjectSearcher.DefaultSearchFilter.GetLdapFilterString(), SearchScope.Base, strArrays);

            aDSearchRequest.TypesOnly = propertyNamesOnly;
            aDSearchRequest.TimeLimit = this._timeLimit;
            ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);

            if (aDSearchResponse.Entries.Count > 0)
            {
                aDRootDSE = new ADRootDSE();
                ADObject item = aDSearchResponse.Entries[0];
                foreach (string propertyName in item.PropertyNames)
                {
                    aDRootDSE.Add(propertyName, item[propertyName]);
                }
            }
            return(aDRootDSE);
        }
示例#3
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");
     }
 }
示例#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
		void Microsoft.ActiveDirectory.Management.IADSyncOperations.AbandonSearch(ADSessionHandle handle, ADSearchRequest request)
		{
			AdwsConnection internalHandle = this.GetInternalHandle(handle);
			if (internalHandle != null)
			{
				internalHandle.AbandonSearch(request);
			}
		}
示例#7
0
		ADSearchResponse Microsoft.ActiveDirectory.Management.IADSyncOperations.Search(ADSessionHandle handle, ADSearchRequest request)
		{
			ADSearchResponse aDSearchResponse = null;
			AdwsConnection internalHandle = this.GetInternalHandle(handle);
			if (internalHandle != null)
			{
				aDSearchResponse = internalHandle.Search(request);
				this.CheckAndThrowReferralException(aDSearchResponse);
				ADStoreAccess.ThrowExceptionForResultCodeError(aDSearchResponse.ResultCode, aDSearchResponse.ErrorMessage, null);
			}
			return aDSearchResponse;
		}
示例#8
0
		public ADRootDSE GetRootDSE()
		{
			this.Init();
			ADRootDSE rootDSE = this._adSession.RootDSE;
			if (rootDSE == null)
			{
				string[] strArrays = new string[2];
				strArrays[0] = "*";
				strArrays[1] = "msDS-PortLDAP";
				ADSearchRequest aDSearchRequest = new ADSearchRequest("", ADObjectSearcher.DefaultSearchFilter.GetLdapFilterString(), SearchScope.Base, strArrays);
				aDSearchRequest.TimeLimit = this._timeLimit;
				ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);
				if (aDSearchResponse.Entries.Count > 0)
				{
					rootDSE = new ADRootDSE();
					ADObject item = aDSearchResponse.Entries[0];
					foreach (string propertyName in item.PropertyNames)
					{
						rootDSE.Add(propertyName, item[propertyName]);
					}
					this._adSession.RootDSE = rootDSE;
				}
				return rootDSE;
			}
			else
			{
				return rootDSE;
			}
		}
示例#9
0
		public ADRootDSE GetRootDSE(ICollection<string> propertyList, bool propertyNamesOnly)
		{
			this.Init();
			ADRootDSE aDRootDSE = null;
			string[] strArrays = null;
			if (propertyList != null)
			{
				strArrays = new string[propertyList.Count];
				propertyList.CopyTo(strArrays, 0);
			}
			ADSearchRequest aDSearchRequest = new ADSearchRequest("", ADObjectSearcher.DefaultSearchFilter.GetLdapFilterString(), SearchScope.Base, strArrays);
			aDSearchRequest.TypesOnly = propertyNamesOnly;
			aDSearchRequest.TimeLimit = this._timeLimit;
			ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);
			if (aDSearchResponse.Entries.Count > 0)
			{
				aDRootDSE = new ADRootDSE();
				ADObject item = aDSearchResponse.Entries[0];
				foreach (string propertyName in item.PropertyNames)
				{
					aDRootDSE.Add(propertyName, item[propertyName]);
				}
			}
			return aDRootDSE;
		}
示例#10
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;
		}
        ADSearchResponse Microsoft.ActiveDirectory.Management.IADSyncOperations.Search(ADSessionHandle handle, ADSearchRequest request)
        {
            ADSearchResponse             aDSearchResponse = null;
            ADDirectoryServiceConnection internalHandle   = this.GetInternalHandle(handle);

            if (internalHandle != null)
            {
                aDSearchResponse = internalHandle.Search(request);
                this.CheckAndThrowReferralException(aDSearchResponse);
                ADStoreAccess.ThrowExceptionForResultCodeError(aDSearchResponse.ResultCode, aDSearchResponse.ErrorMessage, null);
            }
            return(aDSearchResponse);
        }
        void Microsoft.ActiveDirectory.Management.IADSyncOperations.AbandonSearch(ADSessionHandle handle, ADSearchRequest request)
        {
            ADDirectoryServiceConnection internalHandle = this.GetInternalHandle(handle);

            if (internalHandle != null)
            {
                internalHandle.AbandonSearch(request);
            }
        }
 public void AbandonSearch(ADSessionHandle handle, ADSearchRequest request)
 {
     throw new NotImplementedException();
 }
		public void AbandonSearch (ADSessionHandle handle, ADSearchRequest request)
		{
			throw new NotImplementedException ();
		}