diff --git a/apps/user_ldap/css/settings.css b/apps/user_ldap/css/settings.css index 41578e91b6..be03419c2d 100644 --- a/apps/user_ldap/css/settings.css +++ b/apps/user_ldap/css/settings.css @@ -3,13 +3,9 @@ width: 60%; } -.tablecell { - display: table-cell !important; - white-space: nowrap; -} - .tablerow { display: table-row; + white-space: nowrap; } .tablerow input, .tablerow textarea { @@ -78,6 +74,7 @@ .wizSpinner { height: 15px; + margin: 0.3em; } .ldapSettingControls { @@ -100,7 +97,6 @@ #ldap fieldset input, #ldap fieldset textarea { width: 60%; - display: inline-block; } #ldap fieldset p input[type=checkbox] { diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index 3abec1e232..dcaeb70b57 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -192,19 +192,20 @@ var LdapWizard = { '&ldap_serverconfig_chooser='+$('#ldap_serverconfig_chooser').val(); LdapWizard.showSpinner('#ldap_base'); + $('#ldap_base').prop('disabled', 'disabled'); LdapWizard.ajax(param, function(result) { LdapWizard.applyChanges(result); LdapWizard.hideSpinner('#ldap_base'); if($('#ldap_base').val()) { - $('#ldap_base').removeClass('invisible'); LdapWizard.hideInfoBox(); } + $('#ldap_base').prop('disabled', false); }, function (result) { LdapWizard.hideSpinner('#ldap_base'); - $('#ldap_base').removeClass('invisible'); - LdapWizard.showInfoBox('Please specify a port'); + LdapWizard.showInfoBox('Please specify a Base DN'); + $('#ldap_base').prop('disabled', false); } ); } @@ -212,28 +213,28 @@ var LdapWizard = { checkPort: function() { host = $('#ldap_host').val(); - user = $('#ldap_dn').val(); - pass = $('#ldap_agent_password').val(); + port = $('#ldap_port').val(); - if(host && user && pass) { + if(host && !port) { param = 'action=guessPortAndTLS'+ '&ldap_serverconfig_chooser='+$('#ldap_serverconfig_chooser').val(); LdapWizard.showSpinner('#ldap_port'); + $('#ldap_port').prop('disabled', 'disabled'); LdapWizard.ajax(param, function(result) { LdapWizard.applyChanges(result); LdapWizard.hideSpinner('#ldap_port'); if($('#ldap_port').val()) { LdapWizard.checkBaseDN(); - $('#ldap_port').removeClass('invisible'); + $('#ldap_port').prop('disabled', false); LdapWizard.hideInfoBox(); } }, function (result) { LdapWizard.hideSpinner('#ldap_port'); - $('#ldap_port').removeClass('invisible'); - LdapWizard.showInfoBox('Please specify the BaseDN'); + $('#ldap_port').prop('disabled', false); + LdapWizard.showInfoBox('Please specify the Port'); } ); } @@ -461,12 +462,6 @@ var LdapWizard = { }, init: function() { - if($('#ldap_port').val()) { - $('#ldap_port').removeClass('invisible'); - } - if($('#ldap_base').val()) { - $('#ldap_base').removeClass('invisible'); - } LdapWizard.basicStatusCheck(); }, @@ -521,6 +516,8 @@ var LdapWizard = { }, processChanges: function(triggerObj) { + LdapWizard.hideInfoBox(); + if(triggerObj.id == 'ldap_host' || triggerObj.id == 'ldap_port' || triggerObj.id == 'ldap_dn' diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 9428a98e29..0b2a6a540f 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -63,8 +63,6 @@ class Wizard extends LDAPUtility { public function countGroups() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -98,8 +96,6 @@ class Wizard extends LDAPUtility { public function countUsers() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', 'ldapUserFilter', ))) { @@ -130,8 +126,6 @@ class Wizard extends LDAPUtility { public function determineAttributes() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', 'ldapUserFilter', ))) { @@ -160,8 +154,6 @@ class Wizard extends LDAPUtility { private function getUserAttributes() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', 'ldapUserFilter', ))) { @@ -214,8 +206,6 @@ class Wizard extends LDAPUtility { private function determineGroups($dbkey, $confkey, $testMemberOf = true) { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -242,8 +232,6 @@ class Wizard extends LDAPUtility { public function determineGroupMemberAssoc() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapGroupFilter', ))) { return false; @@ -266,8 +254,6 @@ class Wizard extends LDAPUtility { public function determineGroupObjectClasses() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -294,8 +280,6 @@ class Wizard extends LDAPUtility { public function determineUserObjectClasses() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -322,8 +306,6 @@ class Wizard extends LDAPUtility { public function getGroupFilter() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -337,8 +319,6 @@ class Wizard extends LDAPUtility { public function getUserListFilter() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', ))) { return false; @@ -355,13 +335,12 @@ class Wizard extends LDAPUtility { public function getUserLoginFilter() { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapBase', 'ldapUserFilter', ))) { return false; } + $filter = $this->composeLdapFilter(self::LFILTER_LOGIN); if(!$filter) { throw new \Exception('Cannot create filter'); @@ -377,8 +356,6 @@ class Wizard extends LDAPUtility { */ public function guessPortAndTLS() { if(!$this->checkRequirements(array('ldapHost', - 'ldapAgentName', - 'ldapAgentPassword' ))) { return false; } @@ -418,8 +395,6 @@ class Wizard extends LDAPUtility { */ public function guessBaseDN() { if(!$this->checkRequirements(array('ldapHost', - 'ldapAgentName', - 'ldapAgentPassword', 'ldapPort', ))) { return false; @@ -799,7 +774,22 @@ class Wizard extends LDAPUtility { throw new \Exception($error); } + /** + * @brief checks whether a valid combination of agent and password has been + * provided (either two values or nothing for anonymous connect) + * @return boolean, true if everything is fine, false otherwise + * + */ + private function checkAgentRequirements() { + $agent = $this->configuration->ldapAgentName; + $pwd = $this->configuration->ldapAgentPassword; + + return ( (!empty($agent) && !empty($pwd)) + || (empty($agent) && empty($pwd))); + } + private function checkRequirements($reqs) { + $this->checkAgentRequirements(); foreach($reqs as $option) { $value = $this->configuration->$option; if(empty($value)) { @@ -1005,9 +995,9 @@ class Wizard extends LDAPUtility { //In case the port is already provided, we will check this first if($port > 0) { $hostInfo = parse_url($host); - if(is_array($hostInfo) + if(!(is_array($hostInfo) && isset($hostInfo['scheme']) - && stripos($hostInfo['scheme'], 'ldaps') === false) { + && stripos($hostInfo['scheme'], 'ldaps') !== false)) { $portSettings[] = array('port' => $port, 'tls' => true); } $portSettings[] =array('port' => $port, 'tls' => false); diff --git a/apps/user_ldap/templates/part.wizard-server.php b/apps/user_ldap/templates/part.wizard-server.php index 01dd8d0fcb..fde7c36cdd 100644 --- a/apps/user_ldap/templates/part.wizard-server.php +++ b/apps/user_ldap/templates/part.wizard-server.php @@ -32,7 +32,7 @@ /> @@ -56,7 +56,7 @@
- " />