mirror of
https://github.com/anope/anope.git
synced 2026-07-10 09:43:13 +02:00
Fixed m_ldap_authentication not returning anything if the search for an account game back empty
This commit is contained in:
@@ -240,12 +240,16 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
|
||||
for (LDAPMessage *cur = ldap_first_message(this->con, result); cur; cur = ldap_next_message(this->con, cur))
|
||||
{
|
||||
int cur_type = ldap_msgtype(cur);
|
||||
char *dn = ldap_get_dn(this->con, cur);
|
||||
|
||||
LDAPAttributes attributes;
|
||||
|
||||
char *dn = ldap_get_dn(this->con, cur);
|
||||
if (dn != NULL)
|
||||
{
|
||||
attributes["dn"].push_back(dn);
|
||||
ldap_memfree(dn);
|
||||
dn = NULL;
|
||||
}
|
||||
|
||||
switch (cur_type)
|
||||
{
|
||||
@@ -265,7 +269,10 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
|
||||
ldap_result->type = LDAPResult::QUERY_MODIFY;
|
||||
break;
|
||||
case LDAP_RES_SEARCH_RESULT:
|
||||
break; /* Ignore this */
|
||||
// If we get here and ldap_result->type is LDAPResult::QUERY_UNKNOWN
|
||||
// then the result set is empty
|
||||
ldap_result->type = LDAPResult::QUERY_SEARCH;
|
||||
break;
|
||||
default:
|
||||
Log(LOG_DEBUG) << "m_ldap: Unknown msg type " << cur_type;
|
||||
continue;
|
||||
@@ -321,9 +328,6 @@ class LDAPService : public LDAPProvider, public Thread, public Condition
|
||||
}
|
||||
|
||||
ldap_result->messages.push_back(attributes);
|
||||
|
||||
if (dn != NULL)
|
||||
ldap_memfree(dn);
|
||||
}
|
||||
|
||||
ldap_msgfree(result);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user