0

I have a web application and I have a feature of "Browse User Pictures". I have 1700 users. Now I am using Active Directory query to do that like:

DirectorySearcher ldapSearcher = new DirectorySearcher(lrootDSE, strRetrieve);
ldapSearcher.PageSize = 20;
ldapSearcher.SizeLimit = 1700;

But it loads all the information on the go and that slows my application. Can someone let me know a way where I can show user 30 entries per page and fetch only 30 records from Active Directory at a time.

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
sweta shah
  • 47
  • 5

1 Answers1

0

One way is to use the "LDAP Control Extension for Simple Paged Results Manipulation", it is supported by MS Active Directory and allows you to specify how many results you need.

It is defined in RFC2696: http://www.ietf.org/rfc/rfc2696.txt, but is a lot more readable in the MSDN article: http://msdn.microsoft.com/en-us/library/aa366953%28v=VS.85%29.aspx

ShaMan-H_Fel
  • 2,139
  • 17
  • 24
  • Thanks for the reply, but my code is in C#. And I wnat some query which integrates with string strRetrieve = "(&(objectCategory=person)(objectClass=user))"; so that when i write SearchResultCollection results = ldapSearcher.FindAll(); it only finds 30 users at a time. – sweta shah Jun 30 '11 at 20:48
  • Check this http://stackoverflow.com/questions/90652/can-i-get-more-than-1000-records-from-a-directorysearcher-in-asp-net/90668#90668 it is not exactly your case, but I think it can help. – ShaMan-H_Fel Jul 01 '11 at 04:05
  • again findall() will retrieve all the values. My application becomes really slow with that.Is there any alternative way. I want server side paging in synch with client side. So user can see paging and can go to any page they want and at the same time that page's records are fetched from active directory at that time only. I would appreciate your help. – sweta shah Jul 01 '11 at 17:08
  • Try setting `ldapSearcher.SizeLimit = 20` - thus you will force the server to return you only 20 results or so says the documentation at http://msdn.microsoft.com/en-us/library/system.directoryservices.directorysearcher.sizelimit.aspx – ShaMan-H_Fel Jul 01 '11 at 18:00
  • I have done that, but it will only retrieve 20 records. I want paging using active directory so it knows that first 20 records to be fetched on first page and the next 20 records on second pag if user clicks page 2 and so on. – sweta shah Jul 01 '11 at 21:48
  • Now I am trying to cache the active directory data and applying paging to that. Can you send me refrence links for that – sweta shah Jul 01 '11 at 22:35