]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ldapauth.cpp
Compare the result of ldap_search_ext_s to LDAP_SUCCESS....
[user/henk/code/inspircd.git] / src / modules / extra / m_ldapauth.cpp
index 0f1ca74d7834172e92bd853a28c48ce5598b317b..5d71e7389b6efb6b1c7619c6bd1c2cfbb5fc929e 100644 (file)
@@ -208,9 +208,10 @@ public:
                        size_t pos = user->password.find(":");
                        if (pos != std::string::npos)
                        {
-                               res = ldap_search_ext_s(conn, base.c_str(), searchscope, user->password.substr(0, pos).c_str(), NULL, 0, NULL, NULL, NULL, 0, &msg);
+                               std::string cutpassword = user->password.substr(0, pos);
+                               res = ldap_search_ext_s(conn, base.c_str(), searchscope, cutpassword.c_str(), NULL, 0, NULL, NULL, NULL, 0, &msg);
 
-                               if (res)
+                               if (res == LDAP_SUCCESS)
                                {
                                        // Trim the user: prefix, leaving just 'pass' for later password check
                                        user->password = user->password.substr(pos + 1);
@@ -218,7 +219,7 @@ public:
                        }
 
                        // It may have found based on user:pass check above.
-                       if (!res)
+                       if (res != LDAP_SUCCESS)
                        {
                                if (verbose)
                                        ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (LDAP search failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), ldap_err2string(res));