normalise returned attribute names against the LDAP backend
authorAndrew Bartlett <abartlet@samba.org>
Wed, 10 Dec 2008 06:25:28 +0000 (17:25 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 10 Dec 2008 06:25:28 +0000 (17:25 +1100)
AD returns normalised case always, while OpenLDAP returns (far more
sensibly) what is asked for.

This should not matter to a good client, but ldap.py found it, and
poor clients will no doubt be similarly untested.

Andrew Bartlett

source4/dsdb/samdb/ldb_modules/normalise.c

index 3d1986c41403639f78619fcd9543e1714ce4eea8..d21a68f2480399080253667089abbbc67d8d0886 100644 (file)
@@ -113,6 +113,11 @@ static int normalize_search_callback(struct ldb_request *req, struct ldb_reply *
                        if (!attribute) {
                                continue;
                        }
+                       msg->elements[i].name = talloc_strdup(msg->elements, attribute->lDAPDisplayName);
+                       if (!msg->elements[i].name) {
+                               return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
+                       }
+
                        /* Look to see if this attributeSyntax is a DN */
                        if (strcmp(attribute->attributeSyntax_oid, "2.5.5.1") != 0) {
                                continue;
@@ -121,7 +126,7 @@ static int normalize_search_callback(struct ldb_request *req, struct ldb_reply *
                                const char *dn_str;
                                struct ldb_dn *dn = ldb_dn_from_ldb_val(ac, ac->module->ldb, &msg->elements[i].values[j]);
                                if (!dn) {
-                                       return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
+                                       return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_INVALID_DN_SYNTAX);
                                }
                                ret = fix_dn(dn);
                                if (ret != LDB_SUCCESS) {