1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-14 03:53:59 +02:00

finalized ldap support

This commit is contained in:
Marco Dickert
2017-07-03 11:30:11 +02:00
parent 7f1d14bd21
commit f4a7ae2053
3 changed files with 14 additions and 6 deletions

10
ifm.php
View File

@@ -53,7 +53,7 @@ class IFMConfig {
LDAP auth syntax LDAP auth syntax
const auth_source = 'ldap;<ldap_sever_host>:<rootdn>'; const auth_source = 'ldap;<ldap_sever_host>;<rootdn>';
The script will add "uid=<username>," to the rootdn for binding. If your ldap server The script will add "uid=<username>," to the rootdn for binding. If your ldap server
does not use uid for usernames you can change it in the function checkCredentials. does not use uid for usernames you can change it in the function checkCredentials.
@@ -1855,15 +1855,19 @@ ifm.init();
break; break;
case "ldap": case "ldap":
$authenticated = false; $authenticated = false;
list( $ldap_server, $rootdn ) = explode( ":", $srcopt ); list( $ldap_server, $rootdn ) = explode( ";", $srcopt );
$u = "uid=" . $user . "," . $rootdn; $u = "uid=" . $user . "," . $rootdn;
$ds = ldap_connect( $ldap_server ) or ( trigger_error( "Could not reach the ldap server.", E_USER_ERROR ); return false; ); if( ! $ds = ldap_connect( $ldap_server ) ) {
trigger_error( "Could not reach the ldap server.", E_USER_ERROR );
return false;
}
ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 ); ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
if( $ds ) { if( $ds ) {
$ldbind = @ldap_bind( $ds, $u, $pass ); $ldbind = @ldap_bind( $ds, $u, $pass );
if( $ldbind ) { if( $ldbind ) {
$authenticated = true; $authenticated = true;
} else { } else {
trigger_error( ldap_error( $ds ), E_USER_ERROR );
$authenticated = false; $authenticated = false;
} }
ldap_unbind( $ds ); ldap_unbind( $ds );

View File

@@ -53,7 +53,7 @@ class IFMConfig {
LDAP auth syntax LDAP auth syntax
const auth_source = 'ldap;<ldap_sever_host>:<rootdn>'; const auth_source = 'ldap;<ldap_sever_host>;<rootdn>';
The script will add "uid=<username>," to the rootdn for binding. If your ldap server The script will add "uid=<username>," to the rootdn for binding. If your ldap server
does not use uid for usernames you can change it in the function checkCredentials. does not use uid for usernames you can change it in the function checkCredentials.

View File

@@ -633,15 +633,19 @@ class IFM {
break; break;
case "ldap": case "ldap":
$authenticated = false; $authenticated = false;
list( $ldap_server, $rootdn ) = explode( ":", $srcopt ); list( $ldap_server, $rootdn ) = explode( ";", $srcopt );
$u = "uid=" . $user . "," . $rootdn; $u = "uid=" . $user . "," . $rootdn;
$ds = ldap_connect( $ldap_server ) or ( trigger_error( "Could not reach the ldap server.", E_USER_ERROR ); return false; ); if( ! $ds = ldap_connect( $ldap_server ) ) {
trigger_error( "Could not reach the ldap server.", E_USER_ERROR );
return false;
}
ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 ); ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
if( $ds ) { if( $ds ) {
$ldbind = @ldap_bind( $ds, $u, $pass ); $ldbind = @ldap_bind( $ds, $u, $pass );
if( $ldbind ) { if( $ldbind ) {
$authenticated = true; $authenticated = true;
} else { } else {
trigger_error( ldap_error( $ds ), E_USER_ERROR );
$authenticated = false; $authenticated = false;
} }
ldap_unbind( $ds ); ldap_unbind( $ds );