s4:dsdb: add dsdb_module_constrainted_update_int32/64() functions
authorStefan Metzmacher <metze@samba.org>
Thu, 8 Jul 2010 09:32:59 +0000 (11:32 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 9 Jul 2010 07:27:11 +0000 (09:27 +0200)
metze

source4/dsdb/samdb/ldb_modules/util.c

index 29fc8d75088f8a2361b1d9bcace420eb8028e21d..fe7f46cb8bfe90193c70ff9240f186533f136245 100644 (file)
@@ -1042,3 +1042,61 @@ int dsdb_msg_constrainted_update_int64(struct ldb_module *module,
 
        return LDB_SUCCESS;
 }
+
+/*
+  update an int32 attribute safely via a constrained delete/add
+ */
+int dsdb_module_constrainted_update_int32(struct ldb_module *module,
+                                         struct ldb_dn *dn,
+                                         const char *attr,
+                                         const int32_t *old_val,
+                                         const int32_t *new_val)
+{
+       struct ldb_message *msg;
+       int ret;
+
+       msg = ldb_msg_new(module);
+       msg->dn = dn;
+
+       ret = dsdb_msg_constrainted_update_int32(module,
+                                                msg, attr,
+                                                old_val,
+                                                new_val);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(msg);
+               return ret;
+       }
+
+       ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
+       talloc_free(msg);
+       return ret;
+}
+
+/*
+  update an int64 attribute safely via a constrained delete/add
+ */
+int dsdb_module_constrainted_update_int64(struct ldb_module *module,
+                                         struct ldb_dn *dn,
+                                         const char *attr,
+                                         const int64_t *old_val,
+                                         const int64_t *new_val)
+{
+       struct ldb_message *msg;
+       int ret;
+
+       msg = ldb_msg_new(module);
+       msg->dn = dn;
+
+       ret = dsdb_msg_constrainted_update_int64(module,
+                                                msg, attr,
+                                                old_val,
+                                                new_val);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(msg);
+               return ret;
+       }
+
+       ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
+       talloc_free(msg);
+       return ret;
+}