X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fldapauthenticator.cpp;h=620ae5116bb48d284ae66f16817d13183f8b80c7;hb=e212eabe53878a8fa6ecb15909a325ed7dd63283;hp=ae4ea8773518504c7377497eb81a4836bf3453fc;hpb=bcaaebece13e123dc66dc32b59e13956b12f8b4c;p=quassel.git diff --git a/src/core/ldapauthenticator.cpp b/src/core/ldapauthenticator.cpp index ae4ea877..620ae511 100644 --- a/src/core/ldapauthenticator.cpp +++ b/src/core/ldapauthenticator.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -100,15 +100,27 @@ QVariantList LdapAuthenticator::setupData() const } -void LdapAuthenticator::setAuthProperties(const QVariantMap &properties) +void LdapAuthenticator::setAuthProperties(const QVariantMap &properties, + const QProcessEnvironment &environment, + bool loadFromEnvironment) { - _hostName = properties["Hostname"].toString(); - _port = properties["Port"].toInt(); - _bindDN = properties["BindDN"].toString(); - _bindPassword = properties["BindPassword"].toString(); - _baseDN = properties["BaseDN"].toString(); - _filter = properties["Filter"].toString(); - _uidAttribute = properties["UidAttribute"].toString(); + if (loadFromEnvironment) { + _hostName = environment.value("AUTH_LDAP_HOSTNAME"); + _port = environment.value("AUTH_LDAP_PORT").toInt(); + _bindDN = environment.value("AUTH_LDAP_BIND_DN"); + _bindPassword = environment.value("AUTH_LDAP_BIND_PASSWORD"); + _baseDN = environment.value("AUTH_LDAP_BASE_DN"); + _filter = environment.value("AUTH_LDAP_FILTER"); + _uidAttribute = environment.value("AUTH_LDAP_UID_ATTRIBUTE"); + } else { + _hostName = properties["Hostname"].toString(); + _port = properties["Port"].toInt(); + _bindDN = properties["BindDN"].toString(); + _bindPassword = properties["BindPassword"].toString(); + _baseDN = properties["BaseDN"].toString(); + _filter = properties["Filter"].toString(); + _uidAttribute = properties["UidAttribute"].toString(); + } } // TODO: this code is sufficiently general that in the future, perhaps an abstract @@ -142,17 +154,21 @@ UserId LdapAuthenticator::validateUser(const QString &username, const QString &p } -bool LdapAuthenticator::setup(const QVariantMap &settings) +bool LdapAuthenticator::setup(const QVariantMap &settings, + const QProcessEnvironment &environment, + bool loadFromEnvironment) { - setAuthProperties(settings); + setAuthProperties(settings, environment, loadFromEnvironment); bool status = ldapConnect(); return status; } -Authenticator::State LdapAuthenticator::init(const QVariantMap &settings) +Authenticator::State LdapAuthenticator::init(const QVariantMap &settings, + const QProcessEnvironment &environment, + bool loadFromEnvironment) { - setAuthProperties(settings); + setAuthProperties(settings, environment, loadFromEnvironment); bool status = ldapConnect(); if (!status) { @@ -181,6 +197,8 @@ bool LdapAuthenticator::ldapConnect() serverURIArray = serverURI.toLocal8Bit(); res = ldap_initialize(&_connection, serverURIArray); + quInfo() << "LDAP: Connecting to" << serverURI; + if (res != LDAP_SUCCESS) { qWarning() << "Could not connect to LDAP server:" << ldap_err2string(res); return false;