/// <summary> /// Continues the search for domain members from the current record location. /// </summary> /// <param name="searchContext">Domain provider specific search context returned by FindFirstDomainMembers method.</param> /// <param name="count">Maximum number of member objects to return.</param> /// <param name="memberList">Receives an array object that contains the domain Member objects.</param> /// <returns>True if there are more domain members. Otherwise false is returned.</returns> public bool FindNextDomainMembers(ref string searchContext, int count, out Member[] memberList) { bool moreEntries = false; // Initialize the outputs. memberList = null; // See if there is a valid search context. SearchState searchState = SearchState.GetSearchState(searchContext); if (searchState != null) { // See if entries are to be returned. if (count > 0) { // Get the domain being searched. Domain domain = store.GetDomain(searchState.DomainID); if (domain != null) { // Allocate a list to hold the member objects. ArrayList tempList = new ArrayList(count); ICSEnumerator enumerator = searchState.Enumerator; while ((count > 0) && enumerator.MoveNext()) { // The enumeration returns ShallowNode objects. ShallowNode sn = enumerator.Current as ShallowNode; if (sn.Type == NodeTypes.MemberType) { tempList.Add(new Member(domain, sn)); --count; } } if (tempList.Count > 0) { memberList = tempList.ToArray(typeof(Member)) as Member[]; searchState.CurrentRecord += memberList.Length; searchState.LastCount = memberList.Length; moreEntries = (count == 0) ? true : false; } } } else { if (searchState.CurrentRecord < searchState.TotalRecords) { moreEntries = true; } } } return(moreEntries); }
/// <summary> /// Continues the search for domain members previous to the current record location. /// </summary> /// <param name="searchContext">Domain provider specific search context returned by FindFirstDomainMembers method.</param> /// <param name="count">Maximum number of member objects to return.</param> /// <param name="memberList">Receives an array object that contains the domain Member objects.</param> /// <returns>True if there are more domain members. Otherwise false is returned.</returns> public bool FindPreviousDomainMembers(ref string searchContext, int count, out Member[] memberList) { bool moreEntries = false; // Initialize the outputs. memberList = null; // See if there is a valid search context. SearchState searchState = SearchState.GetSearchState(searchContext); if (searchState != null) { // Backup the current cursor, but don't go passed the first record. if (searchState.CurrentRecord > 0) { bool invalidIndex = false; int cursorIndex = (searchState.CurrentRecord - (searchState.LastCount + count)); if (cursorIndex < 0) { invalidIndex = true; count = searchState.CurrentRecord - searchState.LastCount; cursorIndex = 0; } // Set the new index for the cursor. if (searchState.Enumerator.SetCursor(Simias.Storage.Provider.IndexOrigin.SET, cursorIndex)) { // Reset the current record. searchState.CurrentRecord = cursorIndex; // Complete the search. FindNextDomainMembers(ref searchContext, count, out memberList); if ((invalidIndex == false) && (memberList != null)) { moreEntries = true; } } } } return(moreEntries); }
/// <summary> /// Starts a search for a specific set of domain members. /// </summary> /// <param name="domainID">The identifier of the domain to search for members in.</param> /// <param name="attributeName">Name of attribute to search.</param> /// <param name="searchString">String that contains a pattern to search for.</param> /// <param name="operation">Type of search operation to perform.</param> /// <param name="count">Maximum number of member objects to return.</param> /// <param name="searchContext">Receives a provider specific search context object. This object must be serializable.</param> /// <param name="memberList">Receives an array object that contains the domain Member objects.</param> /// <param name="total">Receives the total number of objects found in the search.</param> /// <returns>True if there are more domain members. Otherwise false is returned.</returns> public bool FindFirstDomainMembers(string domainID, string attributeName, string searchString, SearchOp operation, int count, out string searchContext, out Member[] memberList, out int total) { bool moreEntries = false; // Initialize the outputs. searchContext = null; memberList = null; total = 0; // Start the search for the specific members of the domain. Domain domain = store.GetDomain(domainID); if (domain != null) { ICSList list = domain.Search(attributeName, searchString, operation); SearchState searchState = new SearchState(domainID, list.GetEnumerator() as ICSEnumerator, list.Count); searchContext = searchState.ContextHandle; total = list.Count; moreEntries = FindNextDomainMembers(ref searchContext, count, out memberList); } return(moreEntries); }