PHP Doku:: Liefert den nächsten Eintrag des Ergebnisses - function.ldap-next-entry.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteLightweight Directory Access ProtocolLDAP Funktionenldap_next_entry

Ein Service von Reinhard Neidl - Webprogrammierung.

LDAP Funktionen

<<ldap_next_attribute

ldap_next_reference>>

ldap_next_entry

(PHP 4, PHP 5)

ldap_next_entry Liefert den nächsten Eintrag des Ergebnisses

Beschreibung

resource ldap_next_entry ( resource $Verbindungs-Kennung , resource $Ergebnis-Eintrag-Kennung )

Rückgabewert: Im Erfolgsfall wird die Eintrags-Kennung für den nächsten Eintrag des Ergebnisses zurückgegeben. Das Lesen der Einträge wird mit ldap_first_entry() gestartet. Wenn keine weiteren Einträge im Ergebnis vorhanden sind wird FALSE zurückgegeben.

Die ldap_next_entry() Funktion wird verwendet, um die Einträge zu erhalten, die im Ergebnis gespeichert sind. Wiederholtes aufrufen von ldap_next_entry() liefert einen Eintrag nach dem anderen, solange bis kein Eintrag mehr vorliegt. Der erste Aufruf von ldap_next_entry() erfolgt nach dem Aufruf von ldap_first_entry() mit der Ergebnis-Eintrag-Kennung, die von ldap_first_entry() zurückgegeben wurde.

Siehe auch ldap_get_entries()


4 BenutzerBeiträge:
- Beiträge aktualisieren...
m dot kooijman at student dot utwente dot nl
8.01.2006 13: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.06.2003 2: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.11.2002 5: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.05.2002 20: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 );



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)