s4:samldb LDB module - use appropriate fixed-length integer types where needed
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 16 Oct 2010 12:19:19 +0000 (14:19 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 16 Oct 2010 12:39:23 +0000 (14:39 +0200)
- The "systemFlags" we interpret always as signed
- Use "samdb_msg_add_int" where possible (much saver for integer storing than
  ldb_msg_add_fmt)

source4/dsdb/samdb/ldb_modules/samldb.c

index 9d4f3b86720a88174635d08e3d7dc5b4cee6d82b..3a971e80c565facaea29a7ae0df7ae2b8a10ccf2 100644 (file)
@@ -259,7 +259,7 @@ static bool samldb_krbtgtnumber_available(struct samldb_ctx *ac, unsigned krbtgt
 static int samldb_rodc_add(struct samldb_ctx *ac)
 {
        struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
-       unsigned krbtgt_number, i_start, i;
+       uint32_t krbtgt_number, i_start, i;
        int ret;
        char *newpass;
 
@@ -359,7 +359,7 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
        int ret;
        bool id_exists;
        uint32_t msds_intid;
-       uint32_t system_flags;
+       int32_t system_flags;
        struct ldb_context *ldb;
        struct ldb_result *ldb_res;
        struct ldb_dn *schema_dn;
@@ -389,7 +389,7 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
        }
 
        /* check systemFlags for SCHEMA_BASE_OBJECT flag */
-       system_flags = ldb_msg_find_attr_as_uint(ac->msg, "systemFlags", 0);
+       system_flags = ldb_msg_find_attr_as_int(ac->msg, "systemFlags", 0);
        if (system_flags & SYSTEM_FLAG_SCHEMA_BASE_OBJECT) {
                return LDB_SUCCESS;
        }
@@ -423,7 +423,8 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
                talloc_free(ldb_res);
        } while(id_exists);
 
-       return ldb_msg_add_fmt(ac->msg, "msDS-IntId", "%d", msds_intid);
+       return samdb_msg_add_int(ldb, ac->msg, ac->msg, "msDS-IntId",
+                                msds_intid);
 }