s4-dsdb: added dsdb_module_set_integer()
authorAndrew Tridgell <tridge@samba.org>
Wed, 6 Jan 2010 03:48:55 +0000 (14:48 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 8 Jan 2010 02:03:00 +0000 (13:03 +1100)
This will be used by ridalloc.c

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/dsdb/samdb/ldb_modules/util.c

index 09b41a254bce73265d7b78ca3e824b35439d7df5..12972eb1855f0227f5d3eab408954f32b0b33044 100644 (file)
@@ -597,3 +597,27 @@ int dsdb_next_callback(struct ldb_request *req, struct ldb_reply *ares)
        return up_req->callback(up_req, ares);
 }
 
+
+/*
+  set an integer attribute
+ */
+int dsdb_module_set_integer(struct ldb_module *module, struct ldb_dn *dn,
+                           const char *attr, uint64_t new_val)
+{
+       struct ldb_message *msg;
+       int ret;
+
+       msg = ldb_msg_new(module);
+       msg->dn = dn;
+
+       ret = ldb_msg_add_fmt(msg, attr, "%llu", (unsigned long long)new_val);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(msg);
+               return ret;
+       }
+       msg->elements[0].flags = LDB_FLAG_MOD_REPLACE;
+
+       ret = dsdb_module_modify(module, msg, 0);
+       talloc_free(msg);
+       return ret;
+}