Why does enumerating DirectoryEntry children only return 20 results on a WinNT domain? C#
I'm currently using the following code to find computers in a given WinNT domain, since DirectorySearcher is not supported on WinNT domains;
protected void ScanDomain(string domainName, bool isLocalDomain)
{
DirectoryEntry parentEntry = new DirectoryEntry();
if(isLocalDomain)
{
try
{
parentEntry.Path = "WinNT://" + domainName;
int numResults = 0;
foreach (DirectoryEntry childEntry in parentEntry.Children)
{
switch (childEntry.SchemaClassName)
{
case "Computer":
Debug.WriteLine(childEntry.Name);
numResults++;
break;
}
}
if (numResults == 0)
{
Debug.WriteLine("No results.");
}
}
catch (Exception ex)
{
开发者_开发知识库 Debug.WriteLine("Failed.");
}
}
else
{
//...
}
}
But when using this method, I only receive 20 computer results even though I know there's more computers than that in the domain.
So I was just wondering if anyone had any idea why this is?
Directory Entry returns the children of Specific Node. This will not contain node under nodes, means grand children of that. Try to check for grand children also, and get every node under WIN NT this will work.
Please let me know if you want a code snippet. Or I am missing any thing from my side.
精彩评论