s4-dsdb: added dsdb_modify_permissive()
authorAndrew Tridgell <tridge@samba.org>
Mon, 15 Feb 2010 06:38:16 +0000 (17:38 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 15 Feb 2010 07:58:40 +0000 (18:58 +1100)
This will be used in the drsuapi server

source4/dsdb/common/util.c

index d659767138f8bed4ade8a28670418eac9297aec5..eb021dfc949c52d40f2966fc2e0332a3d7bd5ce0 100644 (file)
@@ -3360,3 +3360,39 @@ int dsdb_load_udv_v1(struct ldb_context *samdb, struct ldb_dn *dn, TALLOC_CTX *m
        talloc_free(v2);
        return LDB_SUCCESS;
 }
+
+
+/*
+  a modify with the 'permissive' control
+  this means no error for entries that already exist on adds, or
+  removal of entries that don't exist
+*/
+int dsdb_modify_permissive(struct ldb_context *ldb,
+                          const struct ldb_message *message)
+{
+       struct ldb_request *req;
+       int ret;
+
+       ret = ldb_build_mod_req(&req, ldb, ldb,
+                               message,
+                               NULL,
+                               NULL,
+                               ldb_op_default_callback,
+                               NULL);
+
+       if (ret != LDB_SUCCESS) return ret;
+
+       ret = ldb_request_add_control(req, LDB_CONTROL_PERMISSIVE_MODIFY_OID, false, NULL);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(req);
+               return ret;
+       }
+
+       ret = ldb_request(ldb, req);
+       if (ret == LDB_SUCCESS) {
+               ret = ldb_wait(req->handle, LDB_WAIT_ALL);
+       }
+
+       talloc_free(req);
+       return ret;
+}