查詢

ldap_control_paged_result_response()函式—用法及示例

「 獲取分頁結果的響應控制元件 」


函式名:ldap_control_paged_result_response()

適用版本:PHP 5, PHP 7

用法:ldap_control_paged_result_response(resource $link, resource $result, array &$cookie, int &$estimated);

說明:ldap_control_paged_result_response() 函式用於獲取分頁結果的響應控制元件。

引數:

  • $link:一個開啟的 LDAP 連線資源。
  • $result:一個搜尋結果資源。
  • &$cookie:一個用於儲存分頁 cookie 值的陣列。
  • &$estimated:一個用於儲存估計的條目數的整數。

返回值:成功時返回 TRUE,失敗時返回 FALSE。

示例:

<?php
// 連線到 LDAP 伺服器
$ldapconn = ldap_connect("ldap.example.com");

// 繫結到 LDAP 目錄
$ldapbind = ldap_bind($ldapconn, "cn=admin,dc=example,dc=com", "password");

// 設定分頁控制
$pageSize = 100;
$cookie = '';
ldap_control_paged_result($ldapconn, $pageSize, true, $cookie);

// 執行搜尋操作
$dn = "ou=users,dc=example,dc=com";
$filter = "(objectClass=*)";
$searchResult = ldap_search($ldapconn, $dn, $filter);

// 獲取分頁結果的響應控制元件
$estimated = 0;
ldap_control_paged_result_response($ldapconn, $searchResult, $cookie, $estimated);

// 列印估計的條目數
echo "估計的條目數:".$estimated;

// 關閉 LDAP 連線
ldap_close($ldapconn);
?>

以上示例演示瞭如何使用 ldap_control_paged_result_response() 函式獲取分頁結果的響應控制元件。在示例中,首先連線到 LDAP 伺服器並繫結到 LDAP 目錄。然後,設定分頁控制並執行搜尋操作。最後,使用 ldap_control_paged_result_response() 函式獲取分頁結果的響應控制元件,並列印出估計的條目數。

請注意,示例中的 LDAP 連線和繫結引數應根據實際情況進行修改。

補充糾錯
上一個函式: ldap_count_entries()函式
熱門PHP函式
分享連結