473,756 Members | 5,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LDAP Search Results

Why does my LDAP query from a C# console app limit its results to 1000? When
I run the same query from a vb script I get over 6000 results. I have tried
to set the SearchRequest.S izeLimit to a value grater than the expected
results and still only get 1000 records. I did notice that in the
LdapConnection constructor I was required to specify the target server where
in the vbs I simply passed an LDAP query to the ADSDSOObject provider. Does
this have something to do with my result set?
Nov 17 '05 #1
4 22641
>Why does my LDAP query from a C# console app limit its results to 1000?

That's by design - you can get around it by explicitly specifying a
"page size" - in that case, the LDAP server will send you the results
in chunks of "page size" items at a time.

Marc
=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
Nov 17 '05 #2
>Why does my LDAP query from a C# console app limit its results to 1000?

That's by design - you can get around it by explicitly specifying a
"page size" - in that case, the LDAP server will send you the results
in chunks of "page size" items at a time.

Marc
=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
Nov 17 '05 #3
Okay, I found an example of using paged serches in the MSDN Library for
VS2005. I copied the paged search section of the code and modified to fit
out AD structure...

---code copy

static void Main(string[] args)
{
//connect to domain controller
LdapConnection ldapConnection = new LdapConnection( "DC1.dot.state. az");

//set filter options
string targetOU = "DC=dot,DC=stat e,DC=az";string ldapSearchFilte r =
"objectClass=co mputer";
string[] attributesToRet urn = { "name" };
int pageSize = 5;

PageResultReque stControl pageRequestCont rol = new
PageResultReque stControl(pageS ize);
PageResultRespo nseControl pageResponseCon trol;
SearchResponse searchResponse;

// create a search request: specify baseDn, ldap search filter, attributes
to return and scope of the search
SearchRequest searchRequest = new SearchRequest(t argetOU, ldapSearchFilte r,
SearchScope.Sub tree, attributesToRet urn);
searchRequest.C ontrols.Add(pag eRequestControl ); //adds the page request
control

int count;

while (true)
{
searchResponse = (SearchResponse )ldapConnection .SendRequest(se archRequest);
Console.WriteLi ne("\r\nPage: " + searchResponse. Entries.Count + " entries:");

//display the entries in this page
count = 0;
foreach (SearchResultEn try entry in searchResponse. Entries)
{
// retrieve a specific attribute
DirectoryAttrib ute attribute = entry.Attribute s["name"];
Console.WriteLi ne(++ count + " " + attribute.Name + " = " + attribute[0]);
}
//retrieve the cookie
if (searchResponse .Controls.Lengt h != 1 || !(searchRespons e.Controls[0] is
PageResultRespo nseControl))
{
Console.WriteLi ne("The server did not return a PageResultRespo nseControl
as expected.");
return;
}
pageResponseCon trol = (PageResultResp onseControl)sea rchResponse.Con trols[0];

//if responseControl .Cookie.Length is 0 then there are no more pages to
retrieve so break the loop
if (pageResponseCo ntrol.Cookie.Le ngth == 0) break;
pageRequestCont rol.Cookie = pageResponseCon trol.Cookie;
}
Console.WriteLi ne("Complete.") ;

--end

This still only returns one page of data with the size limit I set but no
more than 1000.

I set a break point steped through the code. On the first pass, when their
should be more pages waiting, this line of code "if
(pageResponseCo ntrol.Cookie.Le ngth == 0) break;" evaluates to true and the
code breakes out of the loop.

What am I missing?

Thanks!

"Marc Scheuner [MVP ADSI]" wrote:
Why does my LDAP query from a C# console app limit its results to 1000?


That's by design - you can get around it by explicitly specifying a
"page size" - in that case, the LDAP server will send you the results
in chunks of "page size" items at a time.

Marc
=============== =============== =============== =============== ====
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch

Nov 17 '05 #4
>This still only returns one page of data with the size limit I set but no
more than 1000.

What am I missing?


I'm sorry, I'm not intimately familiar with the "low-level" LDAP API
(only working from .NET on the System.Director yServices level), and
quite honestly, I don't see what's wrong with your code here.

Maybe someone else out there has more knowledge of the low-level LDAP
interfaces and can chip in?

Marc
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3599
by: Bjoern Eberth | last post by:
Hi there, i have a few problems accessing a ldap server with the java api JNDI. I am able to get attributes with the following code: env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFact ory"); env.put(Context.PROVIDER_URL, "ldap://server:10389/"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "user=benutzer, ou=irgendwas,
1
3172
by: Dave | last post by:
Could someone fix this for me please. The last bit i cant figure out is the last line in the sub. Results.SetDataBinding(myTable.DefaultView, "") Thanks Dave ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2
10733
by: Neil via .NET 247 | last post by:
I have some code vb.net winforms, that works fine most of the time but stops working occasionally such as right now. The code is this Dim objDE As New DirectoryEntry("LDAP://" & DomainName) Dim objDS As DirectorySearcher = New DirectorySearcher(objDE) Dim results As SearchResultCollection Try objDS.Filter = "(objectClass=user)" 'Find all users results = objDS.FindAll()
2
1426
by: Rosanne Rohana | last post by:
I'm trying for return user info (first name, last name, etc.) from a Netscape 4.16 LDAP server using the System.DirectoryServices. I'm able to get authenticated successfully, but when I attempt to return search results nothing ever comes back. For example, "result = searcher.FindOne()" always returns "nothing" and the "searcher.FindAll" collection always return a count of zero. I've tried many different filters and PropertiesToLoad. Some...
2
4456
by: rufpirat | last post by:
Hello I'm in the middle of trying to build an "AD phone book", and this being my first try at asp.net, I have a few questions that I hope some of you might be able to help with: 1. Is it correct, that PageSize equals the max size of the result set? 2. Is there a way to make asp cache the search result, so the domain controller won't be to bother by all the lookups, and also to speed up
2
2506
by: Steve JORDI | last post by:
Hi, I'm checking a user identity on a secure LDAP server using the following code: $ldapconn = ldap_connect("ldaps://myserver.mycompany.ch", 636 ) or die( "Can't connect to LDAP" ) ; $ldapresult = ldap_search( $ldapconn,"o=mycompany,c=ch","cn=".$name); if( $ldapresult ) {
10
8258
by: Cruelemort | last post by:
All, I am hoping someone would be able to help me with a problem. I have an LDAP server running on a linux box, this LDAP server contains a telephone list in various groupings, the ldif file of which is - dn: dc=example,dc=com objectClass: top objectClass: dcObject objectClass: organization
6
7783
by: hotani | last post by:
I am attempting to pull info from an LDAP server (Active Directory), but cannot specify an OU. In other words, I need to search users in all OU's, not a specific one. Here is what works: con = ldap.initialize("ldap://server.local") con.simple_bind_s('user@domain', pass) result = con.search_ext_s( 'OU=some office, DC=server, DC=local',
2
3938
by: Lars | last post by:
Hi I got some programming experience and I recently started looking into Python. I've read much of the tutorial from 2.6 documentation. But it was more interesting to get started on something I needed. I'm trying to create a script that creates a variable list (just a txt file to be included in bash scripts) with hosts from LDAP. The file will include some static entries and the hosts based on 'cn', 'ipHostNumber' and I might as well set...
0
9454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9868
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9836
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5139
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2664
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.