// The core query operation. // Given a PrincipalSearcher containg a query filter, transforms it into the store schema // and performs the query to get a collection of matching native objects (up to a maximum of sizeLimit, // or uses the sizelimit already set on the DirectorySearcher if sizeLimit == -1). // If the PrincipalSearcher does not have a query filter (PrincipalSearcher.QueryFilter == null), // matches all principals in the store. // // The collection may not be complete, i.e., paging - the returned ResultSet will automatically // page in additional results as needed. internal override ResultSet Query(PrincipalSearcher ps, int sizeLimit) { GlobalDebug.WriteLineIf(GlobalDebug.Info, "ADStoreCtx", "Query"); try { // Set up the DirectorySearcher DirectorySearcher ds = (DirectorySearcher)PushFilterToNativeSearcher(ps); int oldSizeLimit = ds.SizeLimit; Debug.Assert(sizeLimit >= -1); if (sizeLimit != -1) { ds.SizeLimit = sizeLimit; } // Perform the actual search SearchResultCollection src = ds.FindAll(); Debug.Assert(src != null); // Create a ResultSet for the search results ADEntriesSet resultSet = new ADEntriesSet(src, this, ps.QueryFilter.GetType()); ds.SizeLimit = oldSizeLimit; return(resultSet); } catch (System.Runtime.InteropServices.COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(e); } }
// The core query operation. // Given a PrincipalSearcher containg a query filter, transforms it into the store schema // and performs the query to get a collection of matching native objects (up to a maximum of sizeLimit, // or uses the sizelimit already set on the DirectorySearcher if sizeLimit == -1). // If the PrincipalSearcher does not have a query filter (PrincipalSearcher.QueryFilter == null), // matches all principals in the store. // // The collection may not be complete, i.e., paging - the returned ResultSet will automatically // page in additional results as needed. internal override ResultSet Query(PrincipalSearcher ps, int sizeLimit) { GlobalDebug.WriteLineIf(GlobalDebug.Info, "ADStoreCtx", "Query"); try { // Set up the DirectorySearcher DirectorySearcher ds = (DirectorySearcher)PushFilterToNativeSearcher(ps); int oldSizeLimit = ds.SizeLimit; Debug.Assert(sizeLimit >= -1); if (sizeLimit != -1) ds.SizeLimit = sizeLimit; // Perform the actual search SearchResultCollection src = ds.FindAll(); Debug.Assert(src != null); // Create a ResultSet for the search results ADEntriesSet resultSet = new ADEntriesSet(src, this, ps.QueryFilter.GetType()); ds.SizeLimit = oldSizeLimit; return resultSet; } catch (System.Runtime.InteropServices.COMException e) { throw ExceptionHelper.GetExceptionFromCOMException(e); } }