s4:samldb LDB module - support the "userAccountControl" -> "primaryGroupID" detection...
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 15 Sep 2010 12:13:18 +0000 (14:13 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 23 Sep 2010 23:25:42 +0000 (09:25 +1000)
Also requested by MS-SAMR 3.1.1.8.1.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/samldb.c

index dca6ece9eefb283fabde04c183d77ef707ff56ac..d23031522db65ffe9fc19492484439430f21b3c6 100644 (file)
@@ -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)) {