單純做個筆記
// Connecting to LDAP
$ldaphost = "ldap://IP:389";
$ldapconn = ldap_connect($ldaphost) or die("Could not connect to $ldaphost");
//要新增的資料
$addperson["objectClass"][0] = "top";
$addperson["objectClass"][1] = "inetOrgPerson";
$addperson["objectClass"][2] = "person";
$addperson["objectClass"][3] = "qmailUser";
$addperson["mailMessageStore"] = "/var/qmail/maildirs/bojack";
$addperson["qmailDotMode"] = "both";
$addperson["sn"] = "Bojack";
//加密方式有 MD5 or SHA
//$newpassword = "{MD5}" . base64_encode(pack("H*",md5($password)));
$newpassword = "{SHA}".base64_encode(pack("H*",sha1($password)));
$addperson["userPassword"] = $newpassword;
$addperson["mailQuotaSize"] = "104857600";
$addperson["mail"] = "bojack@bojack.com";
$addperson["deliveryMode"] = "nolocal";
$addperson["uid"] = "bojack";
$addperson["accountStatus"] = "active";
$addperson["mailHost"] = "smtp.bojack.com";
$addperson["cn"] = "bojack";
$addperson["deliveryProgramPath"] = "/usr/bin/maildrop -w 95";
$addperson["qmailGID"] = "600";
$addperson["qmailUID"] = "600";
$addperson["mailReplyText"] = " ";
if($ldapconn) {
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_bind($ldapconn,"cn=Manager,dc=bojack,dc=com","Password");
ldap_add($ldapconn,"uid=bojack,ou=user,dc=bojack,dc=com",$addperson);
}
ldap_close($ldapconn);
留言列表