<?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);
}
?>