From: Matt Benjamin Date: Fri, 5 Aug 2016 14:02:03 +0000 (-0400) Subject: rgw ldap: enforce simple_bind w/LDAPv3 X-Git-Tag: ses5-milestone5~208^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F10593%2Fhead;p=ceph.git rgw ldap: enforce simple_bind w/LDAPv3 Found by Harald Klein . Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_ldap.h b/src/rgw/rgw_ldap.h index a427ec46745e..925a1550d504 100644 --- a/src/rgw/rgw_ldap.h +++ b/src/rgw/rgw_ldap.h @@ -70,14 +70,22 @@ namespace rgw { (void) init(); return bind(); } + return -EINVAL; } int simple_bind(const char *dn, const std::string& pwd) { LDAP* tldap; int ret = ldap_initialize(&tldap, uri.c_str()); - ret = ldap_simple_bind_s(tldap, dn, pwd.c_str()); if (ret == LDAP_SUCCESS) { - (void) ldap_unbind(tldap); + unsigned long ldap_ver = LDAP_VERSION3; + ret = ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, + (void*) &ldap_ver); + if (ret == LDAP_SUCCESS) { + ret = ldap_simple_bind_s(tldap, dn, pwd.c_str()); + if (ret == LDAP_SUCCESS) { + (void) ldap_unbind(tldap); + } + } } return ret; // OpenLDAP client error space }