diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index 8dbd3c0462..b922ac99f9 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -20,12 +20,16 @@ * License along with this library. If not, see . * */ -$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter'); +$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter', 'ldap_tls'); foreach($params as $param){ if(isset($_POST[$param])){ OC_Appconfig::setValue('user_ldap', $param, $_POST[$param]); } + elseif('ldap_tls' == $param) { + // unchecked checkboxes are not included in the post paramters + OC_Appconfig::setValue('user_ldap', $param, 0); + } } // fill template diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index 32e1b29daf..374f124174 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -4,9 +4,11 @@

-

+ + Leave both empty for anonymous bind for search, then bind with users credentials.

+

>

diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 4fb8daf3c4..1100be81eb 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -33,6 +33,7 @@ class OC_USER_LDAP extends OC_User_Backend { protected $ldap_password; protected $ldap_base; protected $ldap_filter; + protected $ldap_tls; function __construct() { $this->ldap_host = OC_Appconfig::getValue('user_ldap', 'ldap_host',''); @@ -41,11 +42,11 @@ class OC_USER_LDAP extends OC_User_Backend { $this->ldap_password = OC_Appconfig::getValue('user_ldap', 'ldap_password',''); $this->ldap_base = OC_Appconfig::getValue('user_ldap', 'ldap_base',''); $this->ldap_filter = OC_Appconfig::getValue('user_ldap', 'ldap_filter',''); + $this->ldap_tls = OC_Appconfig::getValue('user_tls', 'ldap_tls', 0); if( !empty($this->ldap_host) && !empty($this->ldap_port) - && !empty($this->ldap_dn) - && !empty($this->ldap_password) + && ((!empty($this->ldap_dn) && !empty($this->ldap_password)) || (empty($this->ldap_dn) && empty($this->ldap_password))) && !empty($this->ldap_base) && !empty($this->ldap_filter) ) @@ -63,9 +64,10 @@ class OC_USER_LDAP extends OC_User_Backend { private function getDs() { if(!$this->ds) { $this->ds = ldap_connect( $this->ldap_host, $this->ldap_port ); - if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3)) - if(ldap_set_option($this->ds, LDAP_OPT_REFERRALS, 0)) - @ldap_start_tls($this->ds); + if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3)) + if(ldap_set_option($this->ds, LDAP_OPT_REFERRALS, 0)) + if($this->ldap_tls) + ldap_start_tls($this->ds); } // login @@ -149,4 +151,4 @@ class OC_USER_LDAP extends OC_User_Backend { } -?> \ No newline at end of file +?>