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

(singke) #1

{


die("Unable to bind to `$dn'!");
}


// create entry
$entry["cn"]="John";
$entry["sn"]="Smith";
$entry["mail"][0]="[email protected]";
$entry["mail"][1]="[email protected]";
$entry["objectclass"]="person";
$entry["telephonenumber"] = "123-123-1234";
$entry["mobile"] = "123-123-1235";
$entry["pager"] = "123-123-1236";
$entry["o"] = "ACME Web Design";
$entry["title"] = "Vice President";
$entry["department"] = "Technology";


//create new entry's DN
$dn = "cn=John Smith, dc=php, dc=net";


//add entry
if(ldap_add($ldap, $dn, $entry))
{
print("Entry Added!\n");
}
else
{
print("Add failed!");
}


//close connection
ldap_close($ldap);
?>


boolean ldap_bind(integer link, string dn, string password)


Use ldap_bind to bind to a directory. Use the optional dn and password arguments
to identify yourself. Servers typically require authentication for any commands that
change the contents of the directory.


boolean ldap_close(integer link)


The ldap_close function closes the connection to the directory server.


integer ldap_connect(string host, integer port)

Free download pdf