summaryrefslogtreecommitdiff
path: root/modules/extra/m_ldap_authentication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/extra/m_ldap_authentication.cpp')
-rw-r--r--modules/extra/m_ldap_authentication.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp
index 8a42553e5..0f0593c34 100644
--- a/modules/extra/m_ldap_authentication.cpp
+++ b/modules/extra/m_ldap_authentication.cpp
@@ -57,17 +57,32 @@ class IdentifyInterface : public LDAPInterface
{
case LDAPResult::QUERY_SEARCH:
{
- try
+ if (!r.empty())
{
- const LDAPAttributes &attr = r.get(0);
- ii->dn = attr.get("dn");
- Log(LOG_DEBUG) << "m_ldap_authenticationn: binding as " << ii->dn;
- LDAPQuery id = ii->lprov->Bind(this, ii->dn, ii->pass);
- this->Add(id, ii);
+ try
+ {
+ const LDAPAttributes &attr = r.get(0);
+ ii->dn = attr.get("dn");
+ Log(LOG_DEBUG) << "m_ldap_authenticationn: binding as " << ii->dn;
+ LDAPQuery id = ii->lprov->Bind(this, ii->dn, ii->pass);
+ this->Add(id, ii);
+ }
+ catch (const LDAPException &ex)
+ {
+ Log() << "m_ldap_authentication: Error binding after search: " << ex.GetReason();
+ delete ii;
+ }
}
- catch (const LDAPException &ex)
+ else
{
- Log() << "m_ldap_authentication: Error binding after search: " << ex.GetReason();
+ User *u = ii->user;
+ Command *c = ii->command;
+
+ u->Extend("m_ldap_authentication_error", NULL);
+
+ c->Execute(ii->source, ii->params);
+
+ delete ii;
}
break;
}