]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ldapauth.cpp
Use CommandBase::Params instead of std::vector<std::string>.
[user/henk/code/inspircd.git] / src / modules / m_ldapauth.cpp
index eee357ec0796dc2e7d290b5044e127340831e79d..fedf02b4dd107f1c7e1c5f694126fc408ee3b12d 100644 (file)
@@ -64,7 +64,7 @@ class BindInterface : public LDAPInterface
                                while (i < text.length() - 1 && isalpha(text[i + 1]))
                                        ++i;
 
-                               std::string key(start, (i - start) + 1);
+                               std::string key(text, start, (i - start) + 1);
                                result.append(replacements[key]);
                        }
                        else
@@ -307,8 +307,8 @@ class ModuleLDAPAuth : public Module
 public:
        ModuleLDAPAuth()
                : LDAP(this, "LDAP")
-               , ldapAuthed("ldapauth", this)
-               , ldapVhost("ldapauth_vhost", this)
+               , ldapAuthed("ldapauth", ExtensionItem::EXT_USER, this)
+               , ldapVhost("ldapauth_vhost", ExtensionItem::EXT_USER, this)
        {
                me = this;
                authed = &ldapAuthed;
@@ -406,9 +406,22 @@ public:
                        return MOD_RES_DENY;
                }
 
+               std::string what;
+               std::string::size_type pos = user->password.find(':');
+               if (pos != std::string::npos)
+               {
+                       what = attribute + "=" + user->password.substr(0, pos);
+
+                       // Trim the user: prefix, leaving just 'pass' for later password check
+                       user->password = user->password.substr(pos + 1);
+               }
+               else
+               {
+                       what = attribute + "=" + (useusername ? user->ident : user->nick);
+               }
+
                try
                {
-                       std::string what = attribute + "=" + (useusername ? user->ident : user->nick);
                        LDAP->BindAsManager(new AdminBindInterface(this, LDAP.GetProvider(), user->uuid, base, what));
                }
                catch (LDAPException &ex)