From f46c6233e75509736f0c2a1c376ccab5c0f22fd2 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Wed, 15 Sep 2010 14:13:18 +0200 Subject: s4:samldb LDB module - support the "userAccountControl" -> "primaryGroupID" detection also on modify operations Also requested by MS-SAMR 3.1.1.8.1. Signed-off-by: Andrew Bartlett --- source4/dsdb/samdb/ldb_modules/samldb.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'source4/dsdb/samdb/ldb_modules/samldb.c') diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index dca6ece9ee..d23031522d 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -1231,24 +1231,19 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) } el2 = ldb_msg_find_element(msg, "isCriticalSystemObject"); el2->flags = LDB_FLAG_MOD_REPLACE; + } + + if (!ldb_msg_find_element(msg, "primaryGroupID")) { + uint32_t rid = ds_uf2prim_group_rid(user_account_control); - /* DCs have primaryGroupID of DOMAIN_RID_DCS */ - if (!ldb_msg_find_element(msg, "primaryGroupID")) { - uint32_t rid; - if (user_account_control & UF_SERVER_TRUST_ACCOUNT) { - rid = DOMAIN_RID_DCS; - } else { - /* read-only DC */ - rid = DOMAIN_RID_READONLY_DCS; - } - ret = samdb_msg_add_uint(ldb, msg, msg, - "primaryGroupID", rid); - if (ret != LDB_SUCCESS) { - return ret; - } - el2 = ldb_msg_find_element(msg, "primaryGroupID"); - el2->flags = LDB_FLAG_MOD_REPLACE; + ret = samdb_msg_add_uint(ldb, msg, msg, + "primaryGroupID", rid); + if (ret != LDB_SUCCESS) { + return ret; } + el2 = ldb_msg_find_element(msg, + "primaryGroupID"); + el2->flags = LDB_FLAG_MOD_REPLACE; } } if (el && (LDB_FLAG_MOD_TYPE(el->flags) == LDB_FLAG_MOD_DELETE)) { -- cgit