DirectoryServices - "The administrative limit for this request was exceeded"

  • Thread starter Thread starter Big Dave
  • Start date Start date
B

Big Dave

Hello All, I was wondering wether anyone could help me
solve what is probably a very easy issue. I keep getting
this damn "The administrative limit for this request was
exceeded" whenever I try to query my LDAP server. Does
anyone have any idea how to fix this. I have tried the
pagesize and the sizelimit to no avail. Please help.
---
Here is my code below:
---
using System;
using System.DirectoryServices;

namespace Accounts_In_Out_C
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the
application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//int ppsize = 5;
///This is my attempt to create
code that will search a LDAP server
DirectoryEntry DirEnt = new
DirectoryEntry("LDAP://somecomputer:389/o=somecompany,
c=somecountry");
DirectorySearcher DirSrc = new
DirectorySearcher(DirEnt);
DirSrc.SearchScope =
SearchScope.Subtree;
DirSrc.ReferralChasing =
ReferralChasingOption.All;
//DirSrc.Filter = "(description =
*)";
DirSrc.SizeLimit = 1000000;
//DirSrc.PageSize = ppsize;
//Console.WriteLine
(DirSrc.PageSize);
try
{
foreach(SearchResult
result in DirSrc.FindAll())
{
DirectoryEntry
dirEntry = result.GetDirectoryEntry();

foreach(string
key in dirEntry.Properties.PropertyNames)
{
//Each
property contains a collection of its own
//that
may contain multiple values
foreach
(object propVal in dirEntry.Properties[key])
{


Console.WriteLine(key + " = " + propVal);

}
}
Console.WriteLine
("---------------");
}
}
catch(Exception ex)
{
Console.WriteLine
(ex.Message);
}



}


}
}
 
Big Dave,

When you uncomment the assignment to the PageSize property, does it
work? From the section of the Platform SDK titled "Retreiving Large Result
Sets", located at (watch for line wrap):

http://msdn.microsoft.com/library/d...s/adsi/adsi/retrieving_large_results_sets.asp

It states:

Many directory servers specify an Administrative Limit for the maximum
number of objects they can return if a client does not specify the page
size. When the Administrative Limit is reached, ADSI generates the
ERROR_DS_ADMIN_LIMIT_EXCEEDED Win32 error.

It looks like you are trying to get a good number of objects. You might
want to consider doing a paged search, and limiting the number of results
returned per page.

Hope this helps.
 
Thanks, Nicholas,

Unfortunately when I uncomment out my pagesize code I get
the following error:

---
5
The value for the property PageSize could not be set.

---

Still don't know why I cant set it.

Dave
-----Original Message-----
Big Dave,

When you uncomment the assignment to the PageSize property, does it
work? From the section of the Platform SDK
titled "Retreiving Large Result
Sets", located at (watch for line wrap):

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/adsi/adsi/retrieving_large_results_sets.asp

It states:

Many directory servers specify an Administrative Limit for the maximum
number of objects they can return if a client does not specify the page
size. When the Administrative Limit is reached, ADSI generates the
ERROR_DS_ADMIN_LIMIT_EXCEEDED Win32 error.

It looks like you are trying to get a good number of objects. You might
want to consider doing a paged search, and limiting the number of results
returned per page.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hello All, I was wondering wether anyone could help me
solve what is probably a very easy issue. I keep getting
this damn "The administrative limit for this request was
exceeded" whenever I try to query my LDAP server. Does
anyone have any idea how to fix this. I have tried the
pagesize and the sizelimit to no avail. Please help.
---
Here is my code below:
---
using System;
using System.DirectoryServices;

namespace Accounts_In_Out_C
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the
application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//int ppsize = 5;
///This is my attempt to create
code that will search a LDAP server
DirectoryEntry DirEnt = new
DirectoryEntry("LDAP://somecomputer:389/o=somecompany,
c=somecountry");
DirectorySearcher DirSrc = new
DirectorySearcher(DirEnt);
DirSrc.SearchScope =
SearchScope.Subtree;
DirSrc.ReferralChasing =
ReferralChasingOption.All;
//DirSrc.Filter = "(description =
*)";
DirSrc.SizeLimit = 1000000;
//DirSrc.PageSize = ppsize;
//Console.WriteLine
(DirSrc.PageSize);
try
{
foreach(SearchResult
result in DirSrc.FindAll())
{
DirectoryEntry
dirEntry = result.GetDirectoryEntry();

foreach(string
key in dirEntry.Properties.PropertyNames)
{
//Each
property contains a collection of its own
//that
may contain multiple values
foreach
(object propVal in dirEntry.Properties[key])
{


Console.WriteLine(key + " = " + propVal);

}
}
Console.WriteLine
("---------------");
}
}
catch(Exception ex)
{
Console.WriteLine
(ex.Message);
}



}


}
}


.
 
Nothing wrong with the code, could it be that the ""Administrative Server
time limit" is set to a (too) low value for this (unrealistic) query?
What OS are you running on the AD server(s)?

Willy.
 
Back
Top