diff options
Diffstat (limited to 'application/libraries/Duser')
-rw-r--r-- | application/libraries/Duser/Duser.php | 2 | ||||
-rw-r--r-- | application/libraries/Duser/drivers/Duser_db.php | 12 | ||||
-rw-r--r-- | application/libraries/Duser/drivers/Duser_ldap.php | 17 |
3 files changed, 27 insertions, 4 deletions
diff --git a/application/libraries/Duser/Duser.php b/application/libraries/Duser/Duser.php index 8005a00bb..0007fabd8 100644 --- a/application/libraries/Duser/Duser.php +++ b/application/libraries/Duser/Duser.php @@ -50,7 +50,7 @@ class Duser extends CI_Driver_Library { protected $_adapter = null; protected $valid_drivers = array( - 'duser_db', 'duser_ldap', 'duser_fluxbb' + 'db', 'ldap', 'fluxbb' ); function __construct() diff --git a/application/libraries/Duser/drivers/Duser_db.php b/application/libraries/Duser/drivers/Duser_db.php index 062da9e54..e1df20f1f 100644 --- a/application/libraries/Duser/drivers/Duser_db.php +++ b/application/libraries/Duser/drivers/Duser_db.php @@ -24,6 +24,10 @@ class Duser_db extends Duser_Driver { { $CI =& get_instance(); + if ($username === null) { + return false; + } + $query = $CI->db->select('username, id, password') ->from('users') ->where('username', $username) @@ -48,6 +52,10 @@ class Duser_db extends Duser_Driver { { $CI =& get_instance(); + if ($username === null) { + return false; + } + $query = $CI->db->select('id') ->from('users') ->where('username', $username) @@ -64,6 +72,10 @@ class Duser_db extends Duser_Driver { { $CI =& get_instance(); + if ($userid === null) { + throw new \exceptions\ApiException("libraries/duser/db/get_email-failed", "User does not exist"); + } + $query = $CI->db->select('email') ->from('users') ->where('id', $userid) diff --git a/application/libraries/Duser/drivers/Duser_ldap.php b/application/libraries/Duser/drivers/Duser_ldap.php index b80385fe0..9481397d0 100644 --- a/application/libraries/Duser/drivers/Duser_ldap.php +++ b/application/libraries/Duser/drivers/Duser_ldap.php @@ -26,15 +26,26 @@ class Duser_ldap extends Duser_Driver { return false; } + if (isset($config['bind_rdn']) && isset($config['bind_password'])) { + ldap_bind($ds, $config['bind_rdn'], $config['bind_password']); + } + + if (isset($config['filter'])) { + $filter = sprintf($config['filter'], $username); + } else { + $filter = $config["username_field"].'='.$username; + } + + switch ($config["scope"]) { case "base": - $r = ldap_read($ds, $config['basedn'], $config["username_field"].'='.$username); + $r = ldap_read($ds, $config['basedn'], $filter); break; case "one": - $r = ldap_list($ds, $config['basedn'], $config["username_field"].'='.$username); + $r = ldap_list($ds, $config['basedn'], $filter); break; case "subtree": - $r = ldap_search($ds, $config['basedn'], $config["username_field"].'='.$username); + $r = ldap_search($ds, $config['basedn'], $filter); break; default: throw new \exceptions\ApiException("libraries/duser/ldap/invalid-ldap-scope", "Invalid LDAP scope"); |