<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="http://bugs.horde.org/themes/feed-rss.xsl" type="text/xsl"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
 <channel>
  <title>Make use of LDAP pagination if available</title>
  <pubDate>Sun, 07 Sep 2008 04:43:10 -0400</pubDate>
  <link>http://bugs.horde.org/ticket/5258</link>
  <atom:link rel="self" type="application/rss+xml" title="Make use of LDAP pagination if available" href="http://bugs.horde.org/ticket/5258/rss" />
  <description>Make use of LDAP pagination if available</description>

  
  
  <item>
   <title>From the nyphp-talk list:

The below code demonstrates how</title>
   <description>From the nyphp-talk list:

The below code demonstrates how to use the pagedResultsControl. The PHP
LDAP API is somewhat course but it should work.

Mike

$continue = true;
while ($continue) {
    $paged_control = array(
                        array(
                            'oid' =&gt; PAGED_CONTROL_OID,
                            'iscritical' =&gt; true,
                            'value' =&gt; ldap_ber_printf ('{iO}',
                                                        PAGE_SIZE, $cookie)
                        )
                     );
    if (!ldap_set_option($l, LDAP_OPT_SERVER_CONTROLS, $paged_control)) {
        echo &quot;Not OK: ldap_set_option (controls)\n&quot;;
        exit;
    }    

    $sr = ldap_search($l, $query, $query_filter, $query_attribs, 0, 0, 0,
                      LDAP_DEREF_NEVER);

    if ($sr === FALSE) {
        echo &quot;Not OK: ldap_search\n&quot;;
        exit;
    }

    if (!ldap_parse_result ($l, $sr, &amp;$errcode, &amp;$matcheddn, &amp;$errmsg,
                            &amp;$referrals, &amp;$serverctrls)) {
        echo &quot;Not OK: ldap_parse_result\n&quot;;
        exit;
    }

    $paged_control_found = FALSE;
    if (isset($serverctrls)) {
        foreach ($serverctrls as $i) {
            if ($i['oid'] == PAGED_CONTROL_OID) {
                ldap_ber_scanf($i['value'], '{iO}', &amp;$pagesize, &amp;$cookie);
                $paged_control_found = TRUE;
                break;
            }
        }
    }
    if (!$paged_control_found) {
        echo &quot;Not OK: paged control not found in response \n&quot;;
        exit;
    }

    // process entries as usual here ...

    if ($cookie == '') {
        $continue = false;
    }
}</description>
   <pubDate>Mon, 16 Apr 2007 00:54:15 -0400</pubDate>
   <link>http://bugs.horde.org/ticket/5258#t31724</link>
  </item>
  

 </channel>
</rss>
