dsdb: Only fetch changed attributes in replmd_update_rpmd
authorAndrew Bartlett <abartlet@samba.org>
Wed, 15 Jun 2016 03:43:55 +0000 (15:43 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 26 Jun 2016 22:18:17 +0000 (00:18 +0200)
This avoids fetching every attribute, including in particular links that may
require additional work to resolve, when we will not look at them anyway

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 0d378202ae18ea2579b41b9344a395beec8437f6..cf49a3c1d4e189e596262923b3dad7a457dde261 100644 (file)
@@ -1407,7 +1407,6 @@ static int replmd_update_rpmd(struct ldb_module *module,
        const struct GUID *our_invocation_id;
        int ret;
        const char * const *attrs = NULL;
-       const char * const attrs1[] = { "replPropertyMetaData", "*", NULL };
        const char * const attrs2[] = { "uSNChanged", "objectClass", "instanceType", NULL };
        struct ldb_result *res;
        struct ldb_context *ldb;
@@ -1415,11 +1414,19 @@ static int replmd_update_rpmd(struct ldb_module *module,
        enum urgent_situation situation;
        bool rmd_is_provided;
        bool rmd_is_just_resorted = false;
-
+       const char *not_rename_attrs[4 + msg->num_elements];
+       
        if (rename_attrs) {
                attrs = rename_attrs;
        } else {
-               attrs = attrs1;
+               for (i = 0; i < msg->num_elements; i++) {
+                       not_rename_attrs[i] = msg->elements[i].name;
+               }
+               not_rename_attrs[i] = "replPropertyMetaData";
+               not_rename_attrs[i+1] = "objectClass";
+               not_rename_attrs[i+2] = "instanceType";
+               not_rename_attrs[i+3] = NULL;
+               attrs = not_rename_attrs;
        }
 
        ldb = ldb_module_get_ctx(module);