|
|
@@ -1,5 +1,3 @@
|
|
|
-#define LDAP_DEPRECATED // FIXME
|
|
|
-
|
|
|
#include <iostream>
|
|
|
#include <sstream>
|
|
|
#include <ldap.h>
|
|
|
@@ -42,7 +40,14 @@ bool LDAPReader::Authenticate(const std::string& username, const std::string& pa
|
|
|
|
|
|
std::stringstream bindDn;
|
|
|
bindDn << attribute << "=" << username << "," << baseDn;
|
|
|
- int err = ldap_simple_bind_s(ldapHandler, bindDn.str().c_str(), password.c_str());
|
|
|
+
|
|
|
+ struct berval bindPw;
|
|
|
+ char passwordCstr[password.length()];
|
|
|
+ strcpy(passwordCstr, password.c_str());
|
|
|
+ bindPw.bv_len = password.length();
|
|
|
+ bindPw.bv_val = passwordCstr;
|
|
|
+
|
|
|
+ int err = ldap_sasl_bind_s(ldapHandler, bindDn.str().c_str(), LDAP_SASL_SIMPLE, &bindPw, nullptr, nullptr, nullptr);
|
|
|
if (err != LDAP_SUCCESS)
|
|
|
std::cerr << "LDAP Bind Error: (" << err << ") " << ldap_err2string(err) << std::endl;
|
|
|
ldap_unbind_ext(ldapHandler, nullptr, nullptr);
|