Location: List Archives

List Archives

This forum is an archive of all posts to our mailing list over the past few years.  The forum is set read only therefore to contribute you will need to join our list community.  See more info about this here.

 

When subscribed to the list you should use your standard email client to send your posts to ActiveDir@mail.activedir.org.

List Archives

Subject: RE : Re: [ActiveDir] Maxpagesize on DC.
Prev Next
You are not authorized to post a reply.

AuthorMessages
boubbhaUser is Offline

Posts:34

03/05/2007 8:33 AM  
Hello Michael, Thank you for your script, That works fine ! :) Best Regards, YannMichael B Allen a écrit: On Thu, 1 Mar 2007 19:40:57 +0100 (CET)Yann wrote:> Hello all ;),> > Due to a limit of 1000 responses returned by my DC when querying AD throught Php script, a user has an error.> > Q1: Is it possible to configure the php script to use Paged Results ? If yes how to do it ?Hi Yann,Yes. But first let me say that the next version of our product has anadvanced LDAP api that supports a variety of controls which includes thepagedResultsControl. The details aren't finalized and the official releasewon't be for another 2-3 weeks but
the code is theorized to function likethe following:$err = NULL;$pagedResultsControl = array('size' => 100);$params = array('pagedResultsControl' => $pagedResultsControl,'scope' => 'sub','attrs' => array('cn'),'filter' => '(objectClass=user));do { $objs = plexcel_search_objects($px, $params);if (is_array($objs) == FALSE) {$err = 'Plexcel error: ' . plexcel_status($px);} else {foreach ($objs as $obj) {echo "cn: " . $obj['cn'] . "\n";}}} while ($err == NULL && $pagedResultsControl['cookie']);if ($pagedResultsControl['cookie']) {// discard server-side pagedResultsControl state$pagedResultsControl['size'] => 0;$params = array('pagedResultsControl' => $pagedResultsControl);plexcel_search_objects($px, $params);}If you're interested in this, contact me off-list and I'll put you onThe Beta List.Now that I've had a chance to plug
my product I can answer your questionmore directly :->The builtin LDAP extension for PHP is a little coarse. It follows theOpenLDAP C API religiously which creates some sharp corners that simplyshouldn't be. And not only that, it uses some old unsafe long deprecatedfunctions (although if you have a sufficiently new version of PHP thismay have been fixed).Anyhow. The code you're looking for goes something like thefollowing. I'll leave it to you do decipher.$continue = true;while ($continue) {$paged_control = array(array('oid' => PAGED_CONTROL_OID,'iscritical' => true,'value' => ldap_ber_printf ('{iO}',PAGE_SIZE, $cookie)));if (!ldap_set_option($l, LDAP_OPT_SERVER_CONTROLS, $paged_control)) {echo "Not OK: ldap_set_option (controls)\n";exit;} $sr = ldap_search($l, $query, $query_filter, $query_attribs, 0, 0, 0,LDAP_DEREF_NEVER);if ($sr === FALSE)
{echo "Not OK: ldap_search\n";exit;} if (!ldap_parse_result ($l, $sr, &$errcode, &$matcheddn, &$errmsg,&$referrals, &$serverctrls)) {echo "Not OK: ldap_parse_result\n";exit;}$paged_control_found = FALSE;if (isset($serverctrls)) {foreach ($serverctrls as $i) {if ($i['oid'] == PAGED_CONTROL_OID) {ldap_ber_scanf($i['value'], '{iO}', &$pagesize, &$cookie);$paged_control_found = TRUE;break;}}}if (!$paged_control_found) {echo "Not OK: paged control not found in response \n";exit;}// process entries as usual here ...if ($cookie == '') {$continue = false;}}-- Michael B AllenPHP Active Directory SSOhttp://www.ioplex.com/List info : http://www.activedir.org/List.aspxList FAQ : http://www.activedir.org/ListFAQ.aspxList archive: http://www.activedir.org/ma/default.aspx

Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
You are not authorized to post a reply.
Forums >ActiveDir Mail List Archive >List Archives > RE : Re: [ActiveDir] Maxpagesize on DC.



ActiveForums 3.7
AdventNet Banner
Friends

Friends

Namescape
Members

Members

MembershipMembership:
Latest New UserLatest:kosciesza69
New TodayNew Today:3
New YesterdayNew Yesterday:1
User CountOverall:4319

People OnlinePeople Online:
VisitorsVisitors:96
MembersMembers:0
TotalTotal:96

Online NowOnline Now:

Ads

Copyright 2008 ActiveDir.org
Terms Of Use