diff --git a/util/db-upgrade-0.1.24-vs-0.1.25.sql b/util/db-upgrade-0.1.24-vs-0.1.25.sql index 78496fb9..e738c44d 100644 --- a/util/db-upgrade-0.1.24-vs-0.1.25.sql +++ b/util/db-upgrade-0.1.24-vs-0.1.25.sql @@ -20,3 +20,9 @@ create unique index `entry` on archiving_rule (`domain`,`from`,`to`,`subject`,`_ alter table retention_rule drop index `entry`; create unique index `entry` on retention_rule (`domain`,`from`,`to`,`subject`,`_size`,`size`,`attachment_name`,`attachment_type`,`_attachment_size`,`attachment_size`,`spam`); + +alter table ldap add column ldap_mail_attr varchar(128) default null; +alter table ldap add column ldap_account_objectclass varchar(128) default null; +alter table ldap add column ldap_distributionlist_attr varchar(128) default null; +alter table ldap add column ldap_distributionlist_objectclass varchar(128) default null; + diff --git a/webui/config.php b/webui/config.php index 2cf8451e..9b031c43 100644 --- a/webui/config.php +++ b/webui/config.php @@ -379,6 +379,8 @@ define('GOOGLE_REDIRECT_URL', SITE_URL . 'google.php'); define('HEALTH_URL', SITE_URL . 'index.php?route=health/health'); define('HEALTH_WORKER_URL', SITE_URL . 'index.php?route=health/worker'); +define('LDAP_TYPE_GENERIC', 'generic_ldap'); + define('ACTION_ALL', 0); define('ACTION_UNKNOWN', 1); define('ACTION_LOGIN', 2); diff --git a/webui/controller/ldap/list.php b/webui/controller/ldap/list.php index 5174ffe6..206de1dd 100644 --- a/webui/controller/ldap/list.php +++ b/webui/controller/ldap/list.php @@ -82,8 +82,10 @@ class ControllerLdapList extends Controller { if ( isset($this->data['errorstring']) ) { // use posted values if they differ from database values (ie - form was submitted but failed validation) - if (isset($this->request->post['ldap_type'])) { $this->data['a']['ldap_type'] = $this->request->post['ldap_type'];} - if (isset($this->request->post['description'])) { $this->data['a']['description'] = $this->request->post['description'];} + /*if (isset($this->request->post['ldap_type'])) { $this->data['a']['ldap_type'] = $this->request->post['ldap_type'];} + if (isset($this->request->post['description'])) { $this->data['a']['description'] = $this->request->post['description'];}*/ + + $this->data['a'] = $this->request->post; } } @@ -119,6 +121,23 @@ class ControllerLdapList extends Controller { $this->error['ldap_bind_pw'] = $this->data['text_field_required']; } + if(isset($this->request->post['ldap_type']) && $this->request->post['ldap_type'] == LDAP_TYPE_GENERIC) { + + if(!isset($this->request->post['ldap_mail_attr']) || strlen($this->request->post['ldap_mail_attr']) < 3) { + $this->error['ldap_mail_attr'] = $this->data['text_field_required']; + } + if(!isset($this->request->post['ldap_account_objectclass']) || strlen($this->request->post['ldap_account_objectclass']) < 3) { + $this->error['ldap_account_objectclass'] = $this->data['text_field_required']; + } + if(!isset($this->request->post['ldap_distributionlist_attr']) || strlen($this->request->post['ldap_distributionlist_attr']) < 3) { + $this->error['ldap_distributionlist_attr'] = $this->data['text_field_required']; + } + if(!isset($this->request->post['ldap_distributionlist_objectclass']) || strlen($this->request->post['ldap_distributionlist_objectclass']) < 3) { + $this->error['ldap_distributionlist_objectclass'] = $this->data['text_field_required']; + } + + } + if (!$this->error) { return true; } else { diff --git a/webui/index.php b/webui/index.php index 1121ddc6..cef8dbcf 100644 --- a/webui/index.php +++ b/webui/index.php @@ -58,7 +58,7 @@ Registry::set('langs', $langs); Registry::set('paging', $paging); Registry::set('themes', $themes); Registry::set('letters', $letters); -Registry::set('ldap_types', array("AD", "iredmail", "lotus", "zimbra")); +Registry::set('ldap_types', array("AD", "iredmail", "lotus", "zimbra", LDAP_TYPE_GENERIC)); Registry::set('health_smtp_servers', $health_smtp_servers); Registry::set('partitions_to_monitor', $partitions_to_monitor); Registry::set('actions', $actions); diff --git a/webui/model/saas/ldap.php b/webui/model/saas/ldap.php index 8eff6e35..85138d0a 100644 --- a/webui/model/saas/ldap.php +++ b/webui/model/saas/ldap.php @@ -6,7 +6,7 @@ class ModelSaasLdap extends Model public function get($id = -1) { if(is_numeric($id) && $id >= 0) { - $query = $this->db->query("SELECT id, description, ldap_type, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_bind_pw, ldap_auditor_member_dn FROM " . TABLE_LDAP . " WHERE id=?", array($id)); + $query = $this->db->query("SELECT * FROM " . TABLE_LDAP . " WHERE id=?", array($id)); if($query->num_rows > 0) { return $query->row; } } @@ -43,7 +43,7 @@ class ModelSaasLdap extends Model public function add($arr = array()) { if(!isset($arr['description']) || !isset($arr['ldap_host'])) { return 0; } - $query = $this->db->query("INSERT INTO " . TABLE_LDAP . " (description, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_bind_pw, ldap_type, ldap_auditor_member_dn) VALUES (?,?,?,?,?,?,?)", array($arr['description'], $arr['ldap_host'], $arr['ldap_base_dn'], $arr['ldap_bind_dn'], $arr['ldap_bind_pw'], $arr['ldap_type'], $arr['ldap_auditor_member_dn'])); + $query = $this->db->query("INSERT INTO " . TABLE_LDAP . " (description, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_bind_pw, ldap_type, ldap_auditor_member_dn, ldap_mail_attr, ldap_account_objectclass, ldap_distributionlist_attr, ldap_distributionlist_objectclass) VALUES (?,?,?,?,?,?,?,?,?,?,?)", array($arr['description'], $arr['ldap_host'], $arr['ldap_base_dn'], $arr['ldap_bind_dn'], $arr['ldap_bind_pw'], $arr['ldap_type'], $arr['ldap_auditor_member_dn'], $arr['ldap_mail_attr'], $arr['ldap_account_objectclass'], $arr['ldap_distributionlist_attr'], $arr['ldap_distributionlist_objectclass'])); $rc = $this->db->countAffected(); @@ -58,7 +58,7 @@ class ModelSaasLdap extends Model public function update($arr = array()) { if(!isset($arr['id']) || !isset($arr['description']) || !isset($arr['ldap_host'])) { return 0; } - $query = $this->db->query("UPDATE " . TABLE_LDAP . " SET description=?, ldap_host=?, ldap_base_dn=?, ldap_bind_dn=?, ldap_bind_pw=?, ldap_type=?, ldap_auditor_member_dn=? WHERE id=?", array($arr['description'], $arr['ldap_host'], $arr['ldap_base_dn'], $arr['ldap_bind_dn'], $arr['ldap_bind_pw'], $arr['ldap_type'], $arr['ldap_auditor_member_dn'], $arr['id'])); + $query = $this->db->query("UPDATE " . TABLE_LDAP . " SET description=?, ldap_host=?, ldap_base_dn=?, ldap_bind_dn=?, ldap_bind_pw=?, ldap_type=?, ldap_auditor_member_dn=?, ldap_mail_attr=?, ldap_account_objectclass=?, ldap_distributionlist_attr=?, ldap_distributionlist_objectclass=? WHERE id=?", array($arr['description'], $arr['ldap_host'], $arr['ldap_base_dn'], $arr['ldap_bind_dn'], $arr['ldap_bind_pw'], $arr['ldap_type'], $arr['ldap_auditor_member_dn'], $arr['ldap_mail_attr'], $arr['ldap_account_objectclass'], $arr['ldap_distributionlist_attr'], $arr['ldap_distributionlist_objectclass'], $arr['id'])); return $this->db->countAffected(); } @@ -71,9 +71,9 @@ class ModelSaasLdap extends Model list($l,$d) = explode("@", $email); - $query = $this->db->query("SELECT ldap_type, ldap_host, ldap_base_dn, ldap_bind_dn, ldap_bind_pw, ldap_auditor_member_dn FROM " . TABLE_DOMAIN . " as d, " . TABLE_LDAP . " as l where d.ldap_id=l.id and d.domain=?", array($d)); + $query = $this->db->query("SELECT d.*, l.* FROM " . TABLE_DOMAIN . " as d, " . TABLE_LDAP . " as l where d.ldap_id=l.id and d.domain=?", array($d)); - if($query->num_rows > 0) { return array($query->row['ldap_type'], $query->row['ldap_host'], $query->row['ldap_base_dn'], $query->row['ldap_bind_dn'], $query->row['ldap_bind_pw'], $query->row['ldap_auditor_member_dn']); } + if($query->num_rows > 0) { return $query->row; } return array(); } diff --git a/webui/model/user/auth.php b/webui/model/user/auth.php index 8cccfe97..93b79d56 100644 --- a/webui/model/user/auth.php +++ b/webui/model/user/auth.php @@ -85,16 +85,23 @@ class ModelUserAuth extends Model { $a = $this->model_saas_ldap->get_ldap_params_by_email($username); if(count($a) >= 6) { - $ldap_type = $a[0]; - $ldap_host = $a[1]; - $ldap_base_dn = $a[2]; - $ldap_helper_dn = $a[3]; - $ldap_helper_password = $a[4]; - $ldap_auditor_member_dn = $a[5]; + $ldap_type = $a['ldap_type']; + $ldap_host = $a['ldap_host']; + $ldap_base_dn = $a['ldap_base_dn']; + $ldap_helper_dn = $a['ldap_bind_dn']; + $ldap_helper_password = $a['ldap_bind_pw']; + $ldap_auditor_member_dn = $a['ldap_auditor_member_dn']; + + $ldap_mail_attr = $a['ldap_mail_attr']; + $ldap_account_objectclass = $a['ldap_account_objectclass']; + $ldap_distributionlist_attr = $a['ldap_distributionlist_attr']; + $ldap_distributionlist_objectclass = $a['ldap_distributionlist_objectclass']; } } - list($ldap_mail_attr, $ldap_account_objectclass, $ldap_distributionlist_attr, $ldap_distributionlist_objectclass) = get_ldap_attribute_names($ldap_type); + if($ldap_type != LDAP_TYPE_GENERIC) { + list($ldap_mail_attr, $ldap_account_objectclass, $ldap_distributionlist_attr, $ldap_distributionlist_objectclass) = get_ldap_attribute_names($ldap_type); + } if($ldap_mail_attr == 'proxyAddresses') { $username_prefix = 'smtp:'; } diff --git a/webui/view/javascript/piler-in.js b/webui/view/javascript/piler-in.js index dcde62bd..4b8d57f7 100644 --- a/webui/view/javascript/piler-in.js +++ b/webui/view/javascript/piler-in.js @@ -1096,6 +1096,28 @@ var Piler = }, + fix_ldap_display: function() + { + if($('#ldap_type').val() == '') { + $('#ldap_mail_attr_id').show(); + $('#ldap_account_objectclass_id').show(); + $('#ldap_distributionlist_attr_id').show(); + $('#ldap_distributionlist_objectclass_id').show(); + } + else { + $('#ldap_mail_attr').val(''); + $('#ldap_account_objectclass').val(''); + $('#ldap_distributionlist_attr').val(''); + $('#ldap_distributionlist_objectclass').val(''); + + $('#ldap_mail_attr_id').hide(); + $('#ldap_account_objectclass_id').hide(); + $('#ldap_distributionlist_attr_id').hide(); + $('#ldap_distributionlist_objectclass_id').hide(); + } + }, + + fix_page: function() { diff --git a/webui/view/theme/default/templates/ldap/list.tpl b/webui/view/theme/default/templates/ldap/list.tpl index 980ad3b0..55385edb 100644 --- a/webui/view/theme/default/templates/ldap/list.tpl +++ b/webui/view/theme/default/templates/ldap/list.tpl @@ -35,7 +35,7 @@