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) {
+ static 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);
self.assertEqual(len(res), 1)
self.assertEqual(len(res[0]), 0)
+ def test_ldapSearchExplicitNoAttributesOid(self):
+ """Testing ldap search with the no attributes OID 1.1 specified"""
+
+ user_name = "testnoattributesoiduser"
+ user_dn = "CN=%s,%s" % (user_name, self.base_dn)
+ delete_force(self.ldb, user_dn)
+
+ self.ldb.add({"dn": user_dn,
+ "objectClass": "user",
+ "sAMAccountName": user_name})
+
+ res = self.ldb.search(user_dn, scope=SCOPE_BASE, attrs=["1.1"])
+ delete_force(self.ldb, user_dn)
+
+ self.assertEqual(len(res), 1)
+ self.assertEqual(len(res[0]), 0)
+
+ def test_ldapSearchAllAttributes(self):
+ """Testing ldap search with all attributes"""
+
+ user_name = "testallattributesuser"
+ user_dn = "CN=%s,%s" % (user_name, self.base_dn)
+ delete_force(self.ldb, user_dn)
+
+ self.ldb.add({"dn": user_dn,
+ "objectClass": "user",
+ "sAMAccountName": user_name})
+
+ res = self.ldb.search(user_dn, scope=SCOPE_BASE, attrs=["*"])
+ delete_force(self.ldb, user_dn)
+
+ self.assertEqual(len(res), 1)
+ self.assertTrue(len(res[0]) > 3)
+
class BaseDnTests(samba.tests.TestCase):