Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

print($formatter->format(new Java("java.util.Date"))


. "
\n");
?>


LDAP


LDAP is an acronym for Lightweight Directory Access Protocol. It is a universal method
of storing directory information and is a partial implementation of the X.500 standard.
LDAP was first described in RFC 1777 and RFC 1778.


Through TCP/IP, clients can access a centralized address book containing contact
information, public encryption keys, and similar information. Many servers are live on
the Internet. Dante, a nonprofit organization, maintains a list of LDAP servers organized
by country at http://www.dante.net/np/pdi.html. A full discussion of LDAP
is beyond the scope of this book, but abundant information can be found on the Web. A
good starting point is the University of Michigan at http://www.umich.
edu/~dirsvcs/ldap/index.html
.


The functions in this section require either compiling LDAP support into the PHP
module, or loading an extension module with dl. At the time of this writing, no
extension existed for Windows. You can find a suitable LDAP library at the University of
Michigan site stated above.


The LDAP module is the result of collaboration by Amitay Isaacs, Rasmus Lerdorf,
Gerrit Thomson, and Eric Warnke.


boolean ldap_add(integer link, string dn, array entry)


The ldap_add function adds entries to the specified DN at the object level. The entry
argument is an array of the attribute values. If an attribute can have multiple values, the
array element should be an array itself. See the mail attribute in the example below. If
you wish to add attributes at the attribute level, use ldap_mod_add.


<?


//connect to LDAP server
if(!($ldap=ldap_connect("ldap.php.net")))
{
die("Could not connect to LDAP server!");
}


//set login DN
$dn="cn=root, dc=php, dc=net";


//attempt to bind to DN using password
if(!ldap_bind($ldap, $dn, ""))

Free download pdf