From 96b298f3dbfb78e9b866363bdb57a9d1c624a818 Mon Sep 17 00:00:00 2001 From: Aaron Haslett Date: Fri, 22 Mar 2019 11:25:03 +1300 Subject: [PATCH] ildap: converting ldb's [] to ldap's ["1.1"] An LDB request interprets an empty attribute list as a request for no attributes, but LDAP interprets an empty list as a request for all attributes, and ["1.1"] as a request for no attributes, as per RFC4511:4.5.1.8(SearchRequest.attributes). We need to convert [] to ["1.1"] in the ildap module before the request goes out. This patch adds the fix and removes the relevant knownfail. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13852 Signed-off-by: Aaron Haslett --- lib/ldb-samba/ldb_ildap.c | 15 ++++++++++++++- selftest/knownfail.d/ldap | 1 - 2 files changed, 14 insertions(+), 2 deletions(-) delete mode 100644 selftest/knownfail.d/ldap diff --git a/lib/ldb-samba/ldb_ildap.c b/lib/ldb-samba/ldb_ildap.c index 2c32395..57ec30d 100644 --- a/lib/ldb-samba/ldb_ildap.c +++ b/lib/ldb-samba/ldb_ildap.c @@ -489,8 +489,21 @@ static int ildb_search(struct ildb_context *ac) msg->r.SearchRequest.tree = discard_const(req->op.search.tree); for (n = 0; req->op.search.attrs && req->op.search.attrs[n]; n++) /* noop */ ; + + /* + * In LDB, an empty attribute list indicates a request for no + * attributes, but in LDAP no attributes is requested with an + * attribute list of ["1.1"] according to RFC4511:4.5.1.8. + */ + if (req->op.search.attrs && n == 0) { + const char * attrs[] = {"1.1", NULL}; + msg->r.SearchRequest.attributes = attrs; + n = 1; + } else { + msg->r.SearchRequest.attributes = req->op.search.attrs; + } + msg->r.SearchRequest.num_attributes = n; - msg->r.SearchRequest.attributes = req->op.search.attrs; msg->controls = req->controls; return ildb_request_send(ac, msg); diff --git a/selftest/knownfail.d/ldap b/selftest/knownfail.d/ldap deleted file mode 100644 index 64b9b4a..0000000 --- a/selftest/knownfail.d/ldap +++ /dev/null @@ -1 +0,0 @@ -samba4.ldap.python\(ad_dc_default\).*__main__.BasicTests.test_ldapSearchNoAttributes -- 2.7.4