<?php 
$ds=ldap_connect("localhost"); // 假设 LDAP 服务器在此主机上 
 
if ($ds) { 
 $r=ldap_bind($ds,"cn=root, o=My Company, c=US", "secret"); 
 $info["cn"]="Roberto Celestino"; 
 $info["sn"]="Roberto"; 
 $info["mail"]="rcelestino@here.and.now"; 
 $info["objectclass"]="person"; 
 
 // 将数据添加到目录 
 $r=ldap_add($ds, "cn=Celestino Roberto, o=Mi Compania, c=US", $info); 
 // 关闭由标识符 $ds 指向的链接(使用 ldap_connect 获取) 
 ldap_close($ds); 
 
} 
?>