mirror of
https://github.com/YunoHost-Apps/dotclear2_ynh.git
synced 2024-09-03 18:26:29 +02:00
add a try catch block, improve the ldap auth class
This commit is contained in:
parent
810121c232
commit
f6cb024d24
1 changed files with 51 additions and 42 deletions
|
@ -20,7 +20,6 @@ class ldapDcAuth extends dcAuth
|
|||
if ($ds)
|
||||
{
|
||||
ldap_set_option ($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
|
||||
if (ldap_bind($ds, "uid=".$user_id.",ou=users,".$this->base, $pwd))
|
||||
{
|
||||
# search the user in ldap, and get infos
|
||||
|
@ -29,6 +28,8 @@ class ldapDcAuth extends dcAuth
|
|||
$info = ldap_get_entries($ds, $sr);
|
||||
|
||||
if ($info["count"] == 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->con->begin();
|
||||
$cur = $this->con->openCursor($this->user_table);
|
||||
|
@ -71,16 +72,24 @@ class ldapDcAuth extends dcAuth
|
|||
$this->sudo(array($this->core, 'setUserBlogPermissions'), $user_id, 'default', array('usage'=>true)); # Can change this, PR are welcome
|
||||
}
|
||||
$this->con->commit();
|
||||
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
# In case of error we cancel and return "false"
|
||||
$this->con->rollback();
|
||||
return false;
|
||||
}
|
||||
# The previous operations proceeded without error,
|
||||
# we can now call the parent method
|
||||
return parent::checkUser($user_id, $pwd);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error_log("Failed to connect with the user ".$user_id);
|
||||
}
|
||||
# In case of error we cancel and return "false"
|
||||
$this->con->rollback();
|
||||
return false;
|
||||
}
|
||||
return parent::checkUser($user_id, $pwd);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue