s4-samba3sid: the sambaNextRid attribute is actually the previous RID
authorAndrew Tridgell <tridge@samba.org>
Fri, 8 Jan 2010 01:45:29 +0000 (12:45 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 8 Jan 2010 02:03:07 +0000 (13:03 +1100)
Not well named .... though same mistake that MS made with rIDNextRid

source4/dsdb/samdb/ldb_modules/samba3sid.c

index 6ea5742e6dcccb4b820b46efc9ab9e1c74adf422..bb4b58be3ffb38f09c55a1625bdbbc1752aaf98f 100644 (file)
@@ -48,7 +48,7 @@ static int samba3sid_next_sid(struct ldb_module *module,
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        int sambaNextRid, sambaNextGroupRid, sambaNextUserRid;
        struct ldb_message *msg;
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        int sambaNextRid, sambaNextGroupRid, sambaNextUserRid;
        struct ldb_message *msg;
-       uint32_t rid;
+       int rid;
        const char *sambaSID;
 
        ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE,
        const char *sambaSID;
 
        ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE,
@@ -105,7 +105,10 @@ static int samba3sid_next_sid(struct ldb_module *module,
                return ret;
        }
 
                return ret;
        }
 
-       (*sid) = talloc_asprintf(tmp_ctx, "%s-%u", sambaSID, rid);
+       /* sambaNextRid is actually the previous RID .... */
+       rid += 1;
+
+       (*sid) = talloc_asprintf(tmp_ctx, "%s-%d", sambaSID, rid);
        if (!*sid) {
                ldb_module_oom(module);
                talloc_free(tmp_ctx);
        if (!*sid) {
                ldb_module_oom(module);
                talloc_free(tmp_ctx);
@@ -114,7 +117,7 @@ static int samba3sid_next_sid(struct ldb_module *module,
 
        ret = dsdb_module_constrainted_update_integer(module, msg->dn,
                                                      "sambaNextRid",
 
        ret = dsdb_module_constrainted_update_integer(module, msg->dn,
                                                      "sambaNextRid",
-                                                     sambaNextRid, rid+1);
+                                                     sambaNextRid, rid);
        if (ret != LDB_SUCCESS) {
                ldb_asprintf_errstring(ldb,
                                       __location__
        if (ret != LDB_SUCCESS) {
                ldb_asprintf_errstring(ldb,
                                       __location__