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

search for in the

ldap_rename> <ldap_parse_result
Last updated: Fri, 22 Aug 2008

view this page in

ldap_read

(PHP 4, PHP 5)

ldap_readLee una entrada

Descripción

resource ldap_read ( resource $identificador_de_conexion , string $dn_base , string $filtro [, array $atributos [, int $solo_atributos [, int $tamano_limite [, int $tiempo_limite [, int $deref ]]]]] )

Devuelve un identificador de resultado de búsqueda o FALSE en caso de error.

ldap_read() realiza la búsqueda según el filtro especificado en el parámetro filtro con alcance LDAP_SCOPE_BASE, por lo que es equivalente a leer una entrada del directorio.

No se permiten filtros vacios. Si se quiere obtener toda la información de la entrada, se debe usar un filtro del tipo "objectClass=*". Si conoce que tipos de entradas son usadas en el servidor de directorio, es conveniente emplear el filtro apropiado, como por ejemplo "objectClass=inetOrgPerson".

La función admite hasta 5 parámetros opcionales. Consulte las notas de la función ldap_search().

Note: Los parámetros opcionales se añadieron en la versión de PHP 4.0.2: solo_atributos , tamano_limite , tiempo_limite , deref .

A partir de la versión de PHP 4.0.5 también es posible realizar búsquedas paralelas. Vea la función ldap_search() para ver más detalles.



ldap_rename> <ldap_parse_result
Last updated: Fri, 22 Aug 2008
 
add a note add a note User Contributed Notes
ldap_read
me at example dot com
30-Aug-2007 09:23
In the previous example the

$ds = ldap.myserver.com // your ldap server

should be

$ds = ldap_connect( "ldap.myserver.com" ) ; // your ldap server
cnicholl at yahoo dot com
21-Dec-2005 08:21
Clarification of the ldap_read command syntax: 

If you just want to pull certain attributes from an object and you already know it's dn, the ldap_read command can do this as illustrated below.  It will be less overhead than ldap_search.

The string base_dn which is normally used to set the top context for a recursive ldap_search is used slightly differently with this command.  It is used to specify the actual object with the full dn.  (Hopefully this saves someone else a couple hours trying this command out.)

<?php
$ds
= ldap.myserver.com // your ldap server
 
$dn = "cn=username,o=My Company, c=US"; //the object itself instead of the top search level as in ldap_search
 
$filter="(objectclass=*)"; // this command requires some filter
 
$justthese = array("ou", "sn", "givenname", "mail"); //the attributes to pull, which is much more efficient than pulling all attributes if you don't do this
     
$sr=ldap_read($ds, $dn, $filter, $justthese);
         
$entry = ldap_get_entries($ds, $sr);

echo
$entry[0]["mail"][0] . "is the email address of the cn your requested";
echo
$entry[0]["sn"][0] . "is the sn of the cn your requested";
ldap_close($ds);
?>

This prints out the specified users mail and surname for example.
askegg at challenger dot com dot au
21-Aug-2003 11:11
In addition to the above you can also use ldap_list for a ONE scope LDAP search.

PHP does not conform to the RFC's in that it does not use scope parameters.  Instead use ldap_read for a scope of BASE, ldap_list for ONE and ldap_search for SUB.
sbarnum at mac dot com
18-Jul-2001 11:15
This differs from ldap_search() by not recursing down to sub-entries.  if you know the dn of the item you're looking for and only want info on that entry, use ldap_read() and pass it the full dn of the item you want.

It also seems that you'd alway want something like objectclass=* for the filter, since you're only searching on one entry.

ldap_rename> <ldap_parse_result
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites