2 Unix SMB/CIFS implementation.
4 implement the DsAddEntry call
6 Copyright (C) Stefan Metzmacher 2009
7 Copyright (C) Andrew Tridgell 2009
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "librpc/gen_ndr/ndr_drsuapi.h"
25 #include "rpc_server/dcerpc_server.h"
26 #include "rpc_server/common/common.h"
27 #include "dsdb/samdb/samdb.h"
28 #include "lib/ldb/include/ldb_errors.h"
29 #include "param/param.h"
30 #include "librpc/gen_ndr/ndr_drsblobs.h"
31 #include "auth/auth.h"
32 #include "rpc_server/drsuapi/dcesrv_drsuapi.h"
37 WERROR dcesrv_drsuapi_DsAddEntry(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
38 struct drsuapi_DsAddEntry *r)
41 struct drsuapi_bind_state *b_state;
42 struct dcesrv_handle *h;
44 struct drsuapi_DsReplicaObjectIdentifier2 *ids = NULL;
47 NDR_PRINT_FUNCTION_DEBUG(drsuapi_DsAddEntry, NDR_IN, r);
50 /* TODO: check which out level the client supports */
52 ZERO_STRUCTP(r->out.ctr);
54 r->out.ctr->ctr3.level = 1;
55 r->out.ctr->ctr3.error = talloc_zero(mem_ctx, union drsuapi_DsAddEntryError);
57 DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
60 switch (r->in.level) {
62 status = dsdb_origin_objects_commit(b_state->sam_ctx,
64 &r->in.req->req2.first_object,
67 if (!W_ERROR_IS_OK(status)) {
68 r->out.ctr->ctr3.error->info1.status = status;
69 W_ERROR_NOT_OK_RETURN(status);
72 r->out.ctr->ctr3.count = num;
73 r->out.ctr->ctr3.objects = ids;