It seems that you are getting incomplete recordset with Directory Searcher
class
It looks like the same issue we faced before i.e. Microsoft .NET Framework
1.1 Lightweight Directory Access Protocol (LDAP) Client that uses the .NET
DirectorySearcher class to query the Active Directory directory service may
receive an incomplete result set . If this is the problem you are facing
then it is a Known Issue with Directory Searcher class.
Following Microsoft Knowledge Base article gives you more details about
this <http://support.microsoft.com/default.aspx?scid=kb;en-us;833789>.
In order to get the complete results with your current .net installation,
user should catch this exception(refer to the above KB article) and call
MoveNext to retrieve the remaining results. A code snippet looks like:
bool moreResult = false;
SearchResultCollection results = srch.FindAll();
IEnumerator enumerator = results.GetEnumerator();
while(true)
{
try
{
moreResult = enumerator.MoveNext();
}
catch(COMException e)
{
if(e.ErrorCode == unchecked((int)0x800700EA))
continue;
else
throw e;
}
if(moreResult)
{
SearchResult result = (SearchResult) enumerator.Current;
Console.WriteLine(result.Properties["name"][0]);
}
else
break;
}
We also provide a configuration file setting option, that is to say, if
user specifies the following configuration either in app config or machine
config, it will reissue the request and retrieve the results for the user,
so user could continue using the foreach syntax.
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<section name="system.directoryservices"
type="System.DirectoryServices.SearchWaitHandler, System.DirectoryServices,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<system.directoryservices>
<DirectorySearcher waitForPagedSearchData="true" /> // the value
for
waitForPagedSearchData could be either true or false
</system.directoryservices>
</configuration>
Please see if it helps?
Rohit Sinha[MSFT]
Microsoft Developer Support
Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.