user_ldap: add port setting

This commit is contained in:
Dominik Schmidt 2011-06-23 23:17:10 +02:00
parent c8e57d5460
commit 612f8cb954
4 changed files with 15 additions and 2 deletions

View File

@ -23,6 +23,9 @@
require_once('apps/user_ldap/user_ldap.php');
// define LDAP_DEFAULT_PORT
define("OC_USER_BACKEND_LDAP_DEFAULT_PORT", 389);
// register user backend
OC_USER::useBackend( "LDAP" );

View File

@ -29,7 +29,7 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' ))
exit();
}
$params = array('ldap_host', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter');
$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter');
foreach($params as $param){
if(isset($_POST[$param])){
@ -45,4 +45,8 @@ foreach($params as $param){
$value = OC_APPCONFIG::getValue('user_ldap', $param,'');
$tmpl->assign($param, $value);
}
// ldap_port has a default value
$tmpl->assign( 'ldap_port', OC_APPCONFIG::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT));
$tmpl->printPage();

View File

@ -5,6 +5,9 @@
<div>
<span>Host: *</span><span><input type="text" name="ldap_host" width="200" value="<?php echo $_['ldap_host']; ?>"></span>
</div>
<div>
<span>Port: *</span><span><input type="text" name="ldap_port" width="200" value="<?php echo $_['ldap_port']; ?>"></span>
</div>
<div>
<span>DN:<input type="text" name="ldap_dn" width="200" value="<?php echo $_['ldap_dn']; ?>"></span>
</div>

View File

@ -25,15 +25,18 @@ require_once('User/backend.php');
class OC_USER_LDAP extends OC_USER_BACKEND {
public function checkPassword( $uid, $password ) {
$ldap_host = OC_APPCONFIG::getValue('user_ldap', 'ldap_host','');
$ldap_port = OC_APPCONFIG::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT);
$ldap_dn = OC_APPCONFIG::getValue('user_ldap', 'ldap_dn','');
$ldap_password = OC_APPCONFIG::getValue('user_ldap', 'ldap_password','');
$ldap_base = OC_APPCONFIG::getValue('user_ldap', 'ldap_base','');
$ldap_filter = OC_APPCONFIG::getValue('user_ldap', 'ldap_filter','');
// connect to server
$ds = ldap_connect( $ldap_host );
$ds = ldap_connect( $ldap_host, $ldap_port );
if( !$ds )
return false;