Erreur, envoyez le message d'erreur suivant à votre administrateur :
";
var_dump($new);
Evolog::log("Modify error of $uid by $login");
}
} else {
print "
Aucune modification nécessaire.
";
}
print "
";
/*
* Formular for account modification
*/
} else {
$filter="(uid=$uid)";
$sr=ldap_search($ldapconn, $rdn, $filter);
$info = ldap_get_entries($ldapconn, $sr);
// On verifie que le compte existe bien
if ( $info['count'] != 1 ) {
print "
";
}
// Ajouter un compte
} else {
/**
* Account creation
*/
/**
* Set account creation
*/
if ( (isset($_GET['modif'])) && ($_GET['modif'] == 'yes')) {
// Verification coherence des mots de passe
if ( $_POST['pass1'] != $_POST['pass2'] ) {
print "
Erreur, vous avez tape deux mots de passe differents
Erreur, mot de passe invalide
(trop court ou avec des caracteres incorrects)
";
EvoLog::log("Set password failed for $postuid by $login");
exit(1);
}
$cn = Html::justclean(Html::purgeaccents(utf8_decode($_POST['cn'])));
if (badname($postuid)) {
print "
Erreur, $postuid est invalide.";
print "Vous devez avoir entre 2 et 30 caracteres minuscules, chiffres ou";
print " caracteres speciaux (tiret, point ou underscore).
";
EvoLog::log("Add $postuid failed (bad name).");
exit(1);
}
// Compatibilite anciens schemas LDAP
//if (!$conf['evoadmin']['version'] == 1) {
// mail and cn are auto-generated...
$mail = $postuid. "@" .$_SESSION['domain'];
$sn = $cn;
//} else {
// $mail = Html::clean($_POST['mail']);
// $cn = Html::clean($_POST['cn']);
//}
// On verifie que le compte n'est pas deja pris...
if (!$conf['domaines']['ldap']['virtual']) {
if (Ldap::is_what($mail,"mail")) {
print "
Erreur, mail deja present !
";
EvoLog::log("$mail already exists by $login");
exit(1);
}
// ...sinon on le change legerement !
$tmp = 1;
$uid = $postuid;
while (Ldap::is_uid($uid)) {
$tmp++;
$uid = $postuid.$tmp;
}
} else {
$uid = $mail;
if (Ldap::is_uid($uid)) {
print "
Erreur, mail deja present !
";
EvoLog::log("$uid already exists by $login");
exit(1);
}
}
// Cas d'un compte Samba
if (($conf['admin']['what'] == 2) || ($conf['admin']['what'] == 3)) {
$smbgroup = Html::clean($_POST['smbgroup']);
$tmp = getsambagroups('unix');
$gid = $tmp[$smbgroup];
} else {
$gid = getgid($_SESSION['domain']);
}
if ( $gid < 1 ) {
print "Erreur, groupe non detecte...";
exit(1);
}
print "
";
print "
Ajout en cours...
";
// TODO : generer un UID different en LDAP non-virtual !!!
$info["uid"]=$uid;
// recuperer un uid number valide
// TODO : erreur si uid non compris entre 1000 et 29999
if ( $conf['domaines']['ldap']['virtual'] ) {
$info["uidNumber"]= $conf['unix']['uid'];
}
else {
$info["uidNumber"]= getfreeuid();
}
$info["gidNumber"]= $gid;
$info["objectclass"][0] = "posixAccount";
if (!$conf['domaines']['ldap']['virtual']) {
$info["objectclass"][1] = "shadowAccount";
$info["objectclass"][2] = "inetorgperson";
// Choose what objects you want...
if (($conf['admin']['what'] == 1) || ($conf['admin']['what'] == 3)) {
$info["objectclass"][3] = "mailAccount";
} elseif ($conf['admin']['what'] == 2) {
$info["objectclass"][3] = "sambaSamAccount";
}
if ($conf['admin']['what'] == 3) {
$info["objectclass"][4] = "sambaSamAccount";
}
} else {
$info["objectclass"][1] = "organizationalRole";
$info["objectclass"][2] = "mailAccount";
# $info["objectclass"][3] = "amavisAccount";
}
// Compatibilite anciens schemas LDAP
if ($conf['evoadmin']['version'] == 1) {
$info["objectclass"][4] = "mailAlias";
//$info["onlyAlias"] = "FALSE";
$info["spamassassin"][0] = "whitelist_from dupont@seulement-cet-expediteur.com";
$info["spamassassin"][1] = "whitelist_from *@tous-les-mails-de-ce-domaine.com";
}
$info["isActive"] = (isset($_POST['isactive'])) ? "TRUE" : "FALSE";
$info["isAdmin"] = (isset($_POST['isadmin'])) ? "TRUE" : "FALSE";
$info["cn"] = $cn;
if (!$conf['domaines']['ldap']['virtual']) {
$info["loginShell"] = Html::clean($_POST['loginshell']);
$info["sn"] = $sn;
$info["homeDirectory"] = "/home/" .$uid;
// TODO: rajouter un isset pour verifier la presence de ce champ optionnel
if ( $mail != '') {
$info["mail"] = $mail;
}
} else {
$info["homeDirectory"] = "/home/vmail/" .$_SESSION['domain']. "/" .$postuid. "/";
}
// Cas d'un compte mail
if (($conf['admin']['what'] == 1) || ($conf['admin']['what'] == 3)) {
// Aliases
$aliases = $_POST['alias'];
// Compatibilite anciens schemas LDAP et mode "virtuel"
if (($conf['evoadmin']['version'] == 1) || ($conf['domaines']['ldap']['virtual'])) {
// add @domain for each element
array_walk($aliases,'adddomain');
}
if (!$conf['domaines']['onlyone']) {
array_push($aliases,$postuid."@".$_SESSION['domain']);
} else {
array_push($aliases,$uid);
}
// TODO: if ($conf['domaines']['onlyone'] != true) {
// verifier que le domaine des aliases est correct !!
// on vire les valeurs nulles
sort($aliases);
while ( $aliases[0] == NULL ) {
array_shift($aliases);
}
$info["mailacceptinggeneralid"] = $aliases;
// tmartin 26/11/2009 : on ajoute un maildrop dans tous les cas
//if (!$conf['domaines']['ldap']['virtual']) {
$info["maildrop"] = $uid;
//}
$info["accountActive"] = (isset($_POST['accountactive'])) ? "TRUE" : "FALSE";
$info["courierActive"] = (isset($_POST['courieractive'])) ? "TRUE" : "FALSE";
$info["webmailActive"] = (isset($_POST['webmailactive'])) ? "TRUE" : "FALSE";
$info["authsmtpActive"] = (isset($_POST['authsmtpactive'])) ? "TRUE" : "FALSE";
# $info["amavisBypassSpamChecks"] = (isset($_POST['amavisBypassSpamChecks'])) ? "TRUE" : "FALSE";
}
// Cas d'un compte Samba
if (($conf['admin']['what'] == 2) || ($conf['admin']['what'] == 3)) {
$userRid = 2 * $info["uidNumber"] + 1000;
$info["sambaSID"] = $conf['samba']['sid'].'-'.$userRid;
if(!empty($_POST['displayname'])) {
$info["displayName"] = Html::clean($_POST['displayname']);
}
$info["smbActive"] = (isset($_POST['smbactive'])) ? "TRUE" : "FALSE";
$info["sambaDomainName"] = $conf['samba']['dn'];
$tmp = getsambagroups('smb');
$info["sambaPrimaryGroupSID"] = $conf['samba']['sid'] . $tmp[$smbgroup];
$info["sambaPwdLastSet"] = strtotime("now");
$info["sambaLMPassword"] = Ldap::sambalm($_POST['pass1']);
$info["sambaNTPassword"] = Ldap::sambant($_POST['pass1']);
$info["shadowLastChange"] = floor(strtotime("now")/(3600*24));
$info["sambaPwdCanChange"] = "-2";
$info["sambaPwdMustChange"] = "2147483647";
$info["sambaKickoffTime"] = "2147483647";
$info["sambaAcctFlags"] = "[XU ]";
$info["shadowExpire"] = "-1";
$info["shadowInactive"] = "-1";
$info["shadowMax"] = "200";
$info["shadowMin"] = "0";
$info["shadowWarning"] = "30";
$info["shadowFlag"] = "-1";
}
$info["userPassword"] = "{SSHA}" .Ldap::ssha($_POST['pass1']);
$ldapconn = Ldap::lda_connect(LDAP_ADMIN_DN,LDAP_ADMIN_PASS);
// We use uid attribute for DN
$sr=ldap_add($ldapconn,"uid=" .$uid. "," .$rdn, $info);
// test if ldap connection is successful
if ( $sr ) {
if (!$conf['domaines']['ldap']['virtual']) {
// script creation systeme
unix_add($uid,getgid($_SESSION['domain']));
} else {
$headers = 'From: postmaster@'.$_SESSION['domain']. "\r\n" .
'Reply-To: postmaster@'.$_SESSION['domain']. "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($uid, 'Bienvenue', "Mail d'initialisation du compte.", $headers);
}
print "
Ajout effectué.
";
print "";
EvoLog::log("Add user ".$uid);
// notification par mail
mailnotify($info,$_SESSION['domain'],$_POST['pass1']);
} else {
print "
Erreur, envoyez le message d'erreur suivant à votre administrateur :