diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-01-09 17:11:01 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-01-09 18:56:29 +1100 |
commit | acf33e0d58b38c9c621e2dc0837c07a99c95acc2 (patch) | |
tree | 215f7372eda76cf2eff3564806980a5ef30a6098 | |
parent | 8ccedc3ac7f7bf6207d9fc778686592915781a4a (diff) | |
download | samba-acf33e0d58b38c9c621e2dc0837c07a99c95acc2.tar.gz samba-acf33e0d58b38c9c621e2dc0837c07a99c95acc2.tar.bz2 samba-acf33e0d58b38c9c621e2dc0837c07a99c95acc2.zip |
s4-drs: moved the DsWriteAccountSpn call to its own file
-rw-r--r-- | source4/rpc_server/config.mk | 1 | ||||
-rw-r--r-- | source4/rpc_server/drsuapi/dcesrv_drsuapi.c | 75 | ||||
-rw-r--r-- | source4/rpc_server/drsuapi/dcesrv_drsuapi.h | 2 | ||||
-rw-r--r-- | source4/rpc_server/drsuapi/writespn.c | 101 |
4 files changed, 104 insertions, 75 deletions
diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk index 527770a8cd..5ff1bd5722 100644 --- a/source4/rpc_server/config.mk +++ b/source4/rpc_server/config.mk @@ -188,6 +188,7 @@ dcerpc_drsuapi_OBJ_FILES = $(rpc_serversrcdir)/drsuapi/dcesrv_drsuapi.o \ $(rpc_serversrcdir)/drsuapi/updaterefs.o \ $(rpc_serversrcdir)/drsuapi/getncchanges.o \ $(rpc_serversrcdir)/drsuapi/addentry.o \ + $(rpc_serversrcdir)/drsuapi/writespn.o \ $(rpc_serversrcdir)/drsuapi/drsutil.o ################################################ diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c index 6a6bc8be7e..9edb24edd5 100644 --- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c +++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c @@ -378,81 +378,6 @@ static WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TA return WERR_UNKNOWN_LEVEL; } -/* - drsuapi_DsWriteAccountSpn -*/ -static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct drsuapi_DsWriteAccountSpn *r) -{ - struct drsuapi_bind_state *b_state; - struct dcesrv_handle *h; - - *r->out.level_out = r->in.level; - - DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE); - b_state = h->data; - - r->out.res = talloc(mem_ctx, union drsuapi_DsWriteAccountSpnResult); - W_ERROR_HAVE_NO_MEMORY(r->out.res); - - switch (r->in.level) { - case 1: { - struct drsuapi_DsWriteAccountSpnRequest1 *req; - struct ldb_message *msg; - int count, i, ret; - req = &r->in.req->req1; - count = req->count; - - msg = ldb_msg_new(mem_ctx); - if (msg == NULL) { - return WERR_NOMEM; - } - - msg->dn = ldb_dn_new(msg, b_state->sam_ctx, req->object_dn); - if ( ! ldb_dn_validate(msg->dn)) { - r->out.res->res1.status = WERR_OK; - return WERR_OK; - } - - /* construct mods */ - for (i = 0; i < count; i++) { - samdb_msg_add_string(b_state->sam_ctx, - msg, msg, "servicePrincipalName", - req->spn_names[i].str); - } - for (i=0;i<msg->num_elements;i++) { - switch (req->operation) { - case DRSUAPI_DS_SPN_OPERATION_ADD: - msg->elements[i].flags = LDB_FLAG_MOD_ADD; - break; - case DRSUAPI_DS_SPN_OPERATION_REPLACE: - msg->elements[i].flags = LDB_FLAG_MOD_REPLACE; - break; - case DRSUAPI_DS_SPN_OPERATION_DELETE: - msg->elements[i].flags = LDB_FLAG_MOD_DELETE; - break; - } - } - - /* Apply to database */ - - ret = ldb_modify(b_state->sam_ctx, msg); - if (ret != 0) { - DEBUG(0,("Failed to modify SPNs on %s: %s\n", - ldb_dn_get_linearized(msg->dn), - ldb_errstring(b_state->sam_ctx))); - r->out.res->res1.status = WERR_ACCESS_DENIED; - } else { - r->out.res->res1.status = WERR_OK; - } - - return WERR_OK; - } - } - - return WERR_UNKNOWN_LEVEL; -} - /* drsuapi_DsRemoveDSServer diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.h b/source4/rpc_server/drsuapi/dcesrv_drsuapi.h index 3a64ef5c9c..ba6bb21145 100644 --- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.h +++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.h @@ -47,6 +47,8 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_ struct drsuapi_DsGetNCChanges *r); WERROR dcesrv_drsuapi_DsAddEntry(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct drsuapi_DsAddEntry *r); +WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct drsuapi_DsWriteAccountSpn *r); char *drs_ObjectIdentifier_to_string(TALLOC_CTX *mem_ctx, struct drsuapi_DsReplicaObjectIdentifier *nc); diff --git a/source4/rpc_server/drsuapi/writespn.c b/source4/rpc_server/drsuapi/writespn.c new file mode 100644 index 0000000000..79a6eb55f4 --- /dev/null +++ b/source4/rpc_server/drsuapi/writespn.c @@ -0,0 +1,101 @@ +/* + Unix SMB/CIFS implementation. + + implement the DsWriteAccountSpn call + + Copyright (C) Stefan Metzmacher 2009 + Copyright (C) Andrew Tridgell 2010 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "includes.h" +#include "rpc_server/dcerpc_server.h" +#include "dsdb/samdb/samdb.h" +#include "rpc_server/drsuapi/dcesrv_drsuapi.h" + +/* + drsuapi_DsWriteAccountSpn +*/ +WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, + struct drsuapi_DsWriteAccountSpn *r) +{ + struct drsuapi_bind_state *b_state; + struct dcesrv_handle *h; + + *r->out.level_out = r->in.level; + + DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE); + b_state = h->data; + + r->out.res = talloc(mem_ctx, union drsuapi_DsWriteAccountSpnResult); + W_ERROR_HAVE_NO_MEMORY(r->out.res); + + switch (r->in.level) { + case 1: { + struct drsuapi_DsWriteAccountSpnRequest1 *req; + struct ldb_message *msg; + int count, i, ret; + req = &r->in.req->req1; + count = req->count; + + msg = ldb_msg_new(mem_ctx); + if (msg == NULL) { + return WERR_NOMEM; + } + + msg->dn = ldb_dn_new(msg, b_state->sam_ctx, req->object_dn); + if ( ! ldb_dn_validate(msg->dn)) { + r->out.res->res1.status = WERR_OK; + return WERR_OK; + } + + /* construct mods */ + for (i = 0; i < count; i++) { + samdb_msg_add_string(b_state->sam_ctx, + msg, msg, "servicePrincipalName", + req->spn_names[i].str); + } + for (i=0;i<msg->num_elements;i++) { + switch (req->operation) { + case DRSUAPI_DS_SPN_OPERATION_ADD: + msg->elements[i].flags = LDB_FLAG_MOD_ADD; + break; + case DRSUAPI_DS_SPN_OPERATION_REPLACE: + msg->elements[i].flags = LDB_FLAG_MOD_REPLACE; + break; + case DRSUAPI_DS_SPN_OPERATION_DELETE: + msg->elements[i].flags = LDB_FLAG_MOD_DELETE; + break; + } + } + + /* Apply to database */ + + ret = ldb_modify(b_state->sam_ctx, msg); + if (ret != 0) { + DEBUG(0,("Failed to modify SPNs on %s: %s\n", + ldb_dn_get_linearized(msg->dn), + ldb_errstring(b_state->sam_ctx))); + r->out.res->res1.status = WERR_ACCESS_DENIED; + } else { + r->out.res->res1.status = WERR_OK; + } + + return WERR_OK; + } + } + + return WERR_UNKNOWN_LEVEL; +} |