Return per-entry controls in ldb_module_send_entry()
[abartlet/samba.git/.git] / source4 / dsdb / samdb / ldb_modules / normalise.c
index 796edec98d00811ba9b726cd72bafac920600349..f938672f965a886faa1be2a8562a035adc8a8fd6 100644 (file)
@@ -113,15 +113,20 @@ 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) {
+                       if (strcmp(attribute->attributeSyntax_oid, "2.5.5.1") != 0) {
                                continue;
                        }
                        for (j = 0; j < msg->elements[i].num_values; j++) {
                                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) {
@@ -133,7 +138,7 @@ static int normalize_search_callback(struct ldb_request *req, struct ldb_reply *
                        }
                }
 
-               return ldb_module_send_entry(ac->req, msg);
+               return ldb_module_send_entry(ac->req, msg, ares->controls);
 
        case LDB_REPLY_REFERRAL: