LDAP 函数
在线手册:中文 英文
PHP手册

ldap_next_entry

(PHP 4, PHP 5)

ldap_next_entryGet next result entry

说明

resource ldap_next_entry ( resource $link_identifier , resource $result_entry_identifier )

Retrieve the entries stored in the result. Successive calls to the ldap_next_entry() return entries one by one till there are no more entries. The first call to ldap_next_entry() is made after the call to ldap_first_entry() with the result_entry_identifier as returned from the ldap_first_entry().

参数

link_identifier

An LDAP link identifier, returned by ldap_connect().

result_entry_identifier

返回值

Returns entry identifier for the next entry in the result whose entries are being read starting with ldap_first_entry(). If there are no more entries in the result then it returns FALSE.

参见


LDAP 函数
在线手册:中文 英文
PHP手册
PHP手册 - N: Get next result entry

用户评论:

m dot kooijman at student dot utwente dot nl (08-Jan-2006 12:43)

The code listed below (posted by jeff) to print all attributes with their values is wrong. It keeps trying to index the $entry variable, which is a resource identifier, not an array. All the required information is in the return value of ldap_get_attributes, $attrs.
So:

$entry = ldap_next_entry($conn,$first_entry);
$attrs = ldap_get_attributes($conn,$entry);
for ($i=0; $i < $attrs["count"]; $i++) {
   $attr_name = $attrs[$i];
   for ($j=0; $j < $attrs[$attr_name]["count"]; $j++) {
     echo "$attr_name: ".$attrs["$attr_name"][$j]."\n";
   }
}

jeff at kinkaid dot org (12-Jun-2003 01:24)

dahoo,

Your code to list the attributes of an entry isn't as complete as it could be--just listing the $result["attr"][0] value won't handle multiple-valued attributes. Instead, you should have something like:

$entry = ldap_next_entry($conn,$first_entry);
$attrs = ldap_get_attributes($conn,$entry);
for ($i=0; $i < $entry["count"]; $i++) {
   $attr_name = $entry[$i];
   for ($j=0; $j < $entry[$attr_name]["count"]; $j++) {
      echo "$attr_name: ".$entry["$attr_name"][$j]."\n";
   }
}

This enables you to get listings like:

dn: cn=admin,ou=Groups
cn: admin
objectClass: posixGroup
gidNumber: 500
memberUid: 604
memberUid: 605

(note the two values for "memberUid")

I hope this helps someone.

-Jeff

dahoo at lvye dot org (29-Nov-2002 04:19)

An example :

for($i=ldap_first_entr($connect,$result);
    $arr=ldap_get_attributes($connect,$i);
    $i=ldap_next_entry($connect,$i))
{
    foreach ($arr as $k => $v)
             {
        $myrow[$k]=$arr[$k][0];
    }
}

snameche at virtual-net dot fr (29-May-2002 07:18)

A short example :

$qry = ldap_search( $cxion, $ldap_base, '(cn=seb*)' );

$entry = ldap_first_entry( $cxion, $qry );
while( $entry ){
 $dn = ldap_get_dn( $cxion, $entry );
 echo "<b>$dn</b><br>\n";
 $attrs = ldap_get_attributes( $cxion, $entry );
 for( $i=0; $i<$attrs['count']; $i++ ){
  echo "$attrs[$i]: ";
  for( $j=0; $j<$attrs[$attrs[$i]]['count']; $j++ )
   echo $attrs[$attrs[$i]][$j] . " ";
  echo "<br>\n";
 }
 echo "\<br>\n";
 $entry = ldap_next_entry( $cxion, $entry );
}

ldap_free_result( $qry );