]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:dsdb/common: add a replication metadata stamp for an empty logonHours attribute
authorStefan Metzmacher <metze@samba.org>
Thu, 7 Jul 2016 13:44:47 +0000 (15:44 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 8 Jul 2016 08:01:20 +0000 (10:01 +0200)
When a user object is created it gets a metadata stamp for logonHours,
while the logonHours attribute has no value.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/common/util.c

index ed2dde313553d042bf3b94aad828dbb6ee6ff336..2aed8042d3a83f89d26a570c03c83eaf98c7d58c 100644 (file)
@@ -739,6 +739,7 @@ static int samdb_find_or_add_attribute_ex(struct ldb_context *ldb,
                                          struct ldb_message *msg,
                                          const char *name,
                                          const char *set_value,
+                                         unsigned attr_flags,
                                          bool *added)
 {
        int ret;
@@ -753,11 +754,22 @@ static int samdb_find_or_add_attribute_ex(struct ldb_context *ldb,
                return LDB_SUCCESS;
        }
 
-       ret = ldb_msg_add_string(msg, name, set_value);
+       SMB_ASSERT(set_value != NULL || attr_flags != 0);
+
+       ret = ldb_msg_add_empty(msg, name,
+                               LDB_FLAG_MOD_ADD | attr_flags,
+                               &el);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
-       msg->elements[msg->num_elements - 1].flags = LDB_FLAG_MOD_ADD;
+
+       if (set_value != NULL) {
+               ret = ldb_msg_add_string(msg, name, set_value);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
+               }
+       }
+
        if (added != NULL) {
                *added = true;
        }
@@ -766,7 +778,7 @@ static int samdb_find_or_add_attribute_ex(struct ldb_context *ldb,
 
 int samdb_find_or_add_attribute(struct ldb_context *ldb, struct ldb_message *msg, const char *name, const char *set_value)
 {
-       return samdb_find_or_add_attribute_ex(ldb, msg, name, set_value, NULL);
+       return samdb_find_or_add_attribute_ex(ldb, msg, name, set_value, 0, NULL);
 }
 
 /*
@@ -5294,6 +5306,7 @@ int dsdb_user_obj_set_defaults(struct ldb_context *ldb,
                const char *name;
                const char *value;
                const char *add_control;
+               unsigned attr_flags;
        } map[] = {
                {
                        .name = "accountExpires",
@@ -5327,6 +5340,10 @@ int dsdb_user_obj_set_defaults(struct ldb_context *ldb,
                        .name = "logonCount",
                        .value = "0"
                },
+               {
+                       .name = "logonHours",
+                       .attr_flags = DSDB_FLAG_INTERNAL_FORCE_META_DATA,
+               },
                {
                        .name = "pwdLastSet",
                        .value = "0",
@@ -5340,6 +5357,7 @@ int dsdb_user_obj_set_defaults(struct ldb_context *ldb,
                ret = samdb_find_or_add_attribute_ex(ldb, usr_obj,
                                                     map[i].name,
                                                     map[i].value,
+                                                    map[i].attr_flags,
                                                     &added);
                if (ret != LDB_SUCCESS) {
                        return ret;