diff --git a/htdocs/admin.php b/htdocs/admin.php
index f2dfd7b..0d89f76 100644
--- a/htdocs/admin.php
+++ b/htdocs/admin.php
@@ -25,6 +25,15 @@ if (!empty($_POST['account'])) {
print '';
}
+if (!empty($_POST['alias'])) {
+ $alias = Html::clean($_POST['alias']);
+
+ print '
';
+}
+
if (!empty($_POST['delete'])) {
$account = Html::clean($_POST['delete']);
print '';
@@ -38,6 +47,19 @@ if (!empty($_POST['delete'])) {
print '
';
}
+if (!empty($_POST['delalias'])) {
+ $alias = Html::clean($_POST['delalias']);
+ print '';
+ print '
Suppression de l\'alias '.$alias.' ...
';
+ try {
+ $domain->delAlias($alias);
+ print '
Suppression effectué.
';
+ } catch (Exception $e) {
+ print '
'.$e->getMessage().'
';
+ }
+ print '
';
+}
+
if (!empty($_POST['isactive']) && $server->isSuperAdmin()) {
$active = ($_POST['isactive'] == "TRUE") ? true : false;
try {
diff --git a/htdocs/lib/class.ldapdomain.php b/htdocs/lib/class.ldapdomain.php
index 799e2b5..71e398b 100644
--- a/htdocs/lib/class.ldapdomain.php
+++ b/htdocs/lib/class.ldapdomain.php
@@ -145,6 +145,19 @@ class LdapDomain extends LdapServer {
throw new Exception("Ce compte n'existe pas !");
}
}
+
+ public function delAlias($name) {
+ $dn = "cn=".$name.",cn=".$this->domain.",".LDAP_BASE;
+ if ($sr = @ldap_search($this->conn, $dn, "(ObjectClass=mailAlias)")) {
+ // Delete alias
+ if (!ldap_delete($this->conn, $dn)) {
+ $error = ldap_error($this->conn);
+ throw new Exception("Erreur dans la suppression de l'alias $name : $error");
+ }
+ } else {
+ throw new Exception("Cet alias n'existe pas !");
+ }
+ }
public function update($active=false) {
$info["isActive"] = ($active) ? 'TRUE' : 'FALSE';