Эх сурвалжийг харах

remove deprecated functions

isundil 5 жил өмнө
parent
commit
fb322c81c3
2 өөрчлөгдсөн 8 нэмэгдсэн , 6 устгасан
  1. 8 3
      ldapReader.cpp
  2. 0 3
      test.cpp

+ 8 - 3
ldapReader.cpp

@@ -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);

+ 0 - 3
test.cpp

@@ -2,9 +2,6 @@
 #include <iostream>
 #include "ldapReader.h"
 
-#define LDAP_URI "ldap://localhost:389"
-#define LDAP_ATTRIBUTE "cn"
-#define LDAP_BASEDN "ou=users,dc=example,dc=org"
 #define LDAP_TEST_USERID "foo"
 #define LDAP_TEST_PASSWD "bar"