summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2016-07-07 15:44:47 +0200
committerAndrew Bartlett <abartlet@samba.org>2016-07-08 10:01:20 +0200
commitb0501a1cb0b6503b71a2854a4abba3baae1d4f83 (patch)
treecb78f20bc9fb9ea3de40d4d45801414f87602862 /source4
parentc7307fb7e4b61cec9a70aa56e5cb199a43d79459 (diff)
downloadsamba-b0501a1cb0b6503b71a2854a4abba3baae1d4f83.tar.gz
s4:dsdb/common: add a replication metadata stamp for an empty logonHours attribute
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>
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/common/util.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index ed2dde31355..2aed8042d3a 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -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",
@@ -5328,6 +5341,10 @@ int dsdb_user_obj_set_defaults(struct ldb_context *ldb,
.value = "0"
},
{
+ .name = "logonHours",
+ .attr_flags = DSDB_FLAG_INTERNAL_FORCE_META_DATA,
+ },
+ {
.name = "pwdLastSet",
.value = "0",
.add_control = DSDB_CONTROL_PASSWORD_DEFAULT_LAST_SET_OID,
@@ -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;