downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ldap_count_entries> <ldap_control_paged_result_response
[edit] Last updated: Fri, 17 May 2013

view this page in

ldap_control_paged_result

(PHP 5 >= 5.4.0)

ldap_control_paged_resultLDAP ページネーション制御情報を送信する

説明

bool ldap_control_paged_result ( resource $link , int $pagesize [, bool $iscritical = false [, string $cookie = "" ]] )

LDAP ページネーションを有効にするため、ページネーション制御情報 (ページサイズやクッキーなど) を送信します。

パラメータ

link

ldap_connect() が返す LDAP リンク ID。

pagesize

ページあたりのエントリ数。

iscritical

ページネーションを必須にするかどうか。 true にすると、もしサーバーがページネーションに対応していなければ 検索結果を返しません。

cookie

サーバーから送られる opaque structure ( ldap_control_paged_result_response())。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

次の例は、検索結果の最初のページを取得します。 ページあたり 1 エントリになります。

例1 LDAP ページネーション

<?php
     
// $ds is a valid link identifier (see ldap_connect)
     
ldap_set_option($dsLDAP_OPT_PROTOCOL_VERSION3);

     
$dn        'ou=example,dc=org';
     
$filter    '(|(sn=Doe*)(givenname=John*))';
     
$justthese = array('ou''sn''givenname''mail');

     
// enable pagination with a page size of 1.
     
ldap_control_paged_result($ds1);

     
$sr ldap_search($ds$dn$filter$justthese);

     
$info ldap_get_entries($ds$sr);

     echo 
$info['count'] . ' entries returned' PHP_EOL;

この例は、すべての結果を取得します。 ページあたり 100 エントリとなります。

例2 LDAP ページネーション

<?php
     
// $ds is a valid link identifier (see ldap_connect)
     
ldap_set_option($dsLDAP_OPT_PROTOCOL_VERSION3);

     
$dn        'ou=example,dc=org';
     
$filter    '(|(sn=Doe*)(givenname=John*))';
     
$justthese = array('ou''sn''givenname''mail');

     
// enable pagination with a page size of 100.
     
$pageSize 100;

     
$cookie '';
     do {
         
ldap_control_paged_result($ds$pageSizetrue$cookie);

         
$result  ldap_search($ds$dn$filter$justthese);
         
$entries ldap_get_entries($ds$result);
             
         foreach (
$entries as $e) {
             echo 
$e['dn'] . PHP_EOL;
         }

         
ldap_control_paged_result_response($ds$result$cookie);
       
     } while(
$cookie !== null && $cookie != '');

注意

注意:

ページネーション制御は、LDAPv3 プロトコルの機能です。



ldap_count_entries> <ldap_control_paged_result_response
[edit] Last updated: Fri, 17 May 2013
 
add a note add a note User Contributed Notes ldap_control_paged_result - [3 notes]
up
0
jestertrance at hotmail dot com
2 months ago
You may need to do an ldap_bind before running ldap_control_paged_result to get this to work:

$conn = ldap_connect("you_ip");
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_bind("your_connection_info");       
ldap_control_paged_result($conn, $pageSize, true, $cookie)

Without doing an ldap_bind, I kept getting the error "Critical extension is unavailable". I don't if this is standard knowledge, but knowing this would have saved me days of frustration.
up
0
etienne at lamaisondebarbie dot ch
1 year ago
Paged results, as specified in the RFC 2696, does not allow to get over the server sizeLimit. The RFC clearly states "If the page size is greater than or equal to the sizeLimit value, the server should ignore the control as the request can be satisfied in a single page".
With OpenLDAP, you will not get more than the sizeLimit number of entries with paged results.
up
0
James
1 year ago
I was able to get these functions to work successfully with Active Directory.  When I first tried it, ldap_search kept returning a Not Supported reply from the server.  I finally figured out that I needed to include

ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

in my code, so that AD would let me page results.  Make sure you're using a compatible protocol.

Hope this note helps someone else.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites