| Author | Messages | |
boubbha
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. | | | |
|
|