cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / core / ldapauthenticator.cpp
index 31221fd..89b390f 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   Copyright (C) 2005-2022 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 
 #include "ldapauthenticator.h"
 
-#include "logmessage.h"
+#include "ldapescaper.h"
 #include "network.h"
 #include "quassel.h"
 
 /* We should use openldap on windows if at all possible, rather than trying to
- * write some kind of compatiblity routine.
+ * write some kind of compatibility routine.
 #ifdef Q_CC_MSVC
 #include <windows.h>
 #include <winldap.h>
@@ -129,7 +129,7 @@ UserId LdapAuthenticator::validateUser(const QString& username, const QString& p
     // Users created via LDAP have empty passwords, but authenticator column = LDAP.
     // On the other hand, if auth succeeds and the user already exists, do a final
     // cross-check to confirm we're using the right auth provider.
-    UserId quasselId = Core::validateUser(lUsername, QString());
+    UserId quasselId = Core::getUserId(lUsername);
     if (!quasselId.isValid()) {
         return Core::addUser(lUsername, QString(), backendId());
     }
@@ -152,11 +152,11 @@ Authenticator::State LdapAuthenticator::init(const QVariantMap& settings, const
 
     bool status = ldapConnect();
     if (!status) {
-        quInfo() << qPrintable(backendId()) << "authenticator cannot connect.";
+        qInfo() << qPrintable(backendId()) << "authenticator cannot connect.";
         return NotAvailable;
     }
 
-    quInfo() << qPrintable(backendId()) << "authenticator is ready.";
+    qInfo() << qPrintable(backendId()) << "authenticator is ready.";
     return IsReady;
 }
 
@@ -177,7 +177,7 @@ bool LdapAuthenticator::ldapConnect()
     serverURIArray = serverURI.toLocal8Bit();
     res = ldap_initialize(&_connection, serverURIArray);
 
-    quInfo() << "LDAP: Connecting to" << serverURI;
+    qInfo() << "LDAP: Connecting to" << serverURI;
 
     if (res != LDAP_SUCCESS) {
         qWarning() << "Could not connect to LDAP server:" << ldap_err2string(res);
@@ -242,7 +242,7 @@ bool LdapAuthenticator::ldapAuth(const QString& username, const QString& passwor
 
     LDAPMessage *msg = nullptr, *entry = nullptr;
 
-    const QByteArray ldapQuery = "(&(" + uidAttribute + '=' + username.toLocal8Bit() + ")" + _filter.toLocal8Bit() + ")";
+    const QByteArray ldapQuery = "(&(" + uidAttribute + '=' + LdapEscaper::escapeQuery(username).toLatin1() + ")" + _filter.toLocal8Bit() + ")";
 
     res = ldap_search_ext_s(_connection,
                             baseDN.constData(),