summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-12-19 05:01:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:07:30 -0500
commitc6a420fd1ebe3f95d1c463469868e00b048e92c8 (patch)
treea7400396931cf53be7b018028270953d29f75e5a
parentf7b794c921fb1795fda886262d633040750a416f (diff)
downloadsamba-c6a420fd1ebe3f95d1c463469868e00b048e92c8.tar.gz
samba-c6a420fd1ebe3f95d1c463469868e00b048e92c8.tar.bz2
samba-c6a420fd1ebe3f95d1c463469868e00b048e92c8.zip
r4276: added server side support for lsa_OpenAccount()
(This used to be commit 4716334502a245bc1ffafd3a8a00662cfbdf8ba8)
-rw-r--r--source4/rpc_server/lsa/dcesrv_lsa.c75
1 files changed, 73 insertions, 2 deletions
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index 5b1323dcff..f184c97db8 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -51,6 +51,18 @@ struct lsa_policy_state {
/*
+ state associated with a lsa_OpenAccount() operation
+*/
+struct lsa_account_state {
+ struct lsa_policy_state *policy;
+ uint32_t access_mask;
+ struct dom_sid *account_sid;
+ const char *account_sid_str;
+ const char *account_name;
+};
+
+
+/*
destroy an open policy. This closes the database connection
*/
static void lsa_Policy_destroy(struct dcesrv_connection *conn, struct dcesrv_handle *h)
@@ -59,6 +71,15 @@ static void lsa_Policy_destroy(struct dcesrv_connection *conn, struct dcesrv_han
talloc_free(state);
}
+/*
+ destroy an open account.
+*/
+static void lsa_Account_destroy(struct dcesrv_connection *conn, struct dcesrv_handle *h)
+{
+ struct lsa_account_state *astate = h->data;
+ talloc_free(astate);
+}
+
/*
lsa_Close
*/
@@ -682,9 +703,59 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
lsa_OpenAccount
*/
static NTSTATUS lsa_OpenAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct lsa_OpenAccount *r)
+ struct lsa_OpenAccount *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+ struct dcesrv_handle *h, *ah;
+ struct lsa_policy_state *state;
+ struct lsa_account_state *astate;
+
+ ZERO_STRUCTP(r->out.acct_handle);
+
+ DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY);
+
+ state = h->data;
+
+ astate = talloc_p(dce_call->conn, struct lsa_account_state);
+ if (astate == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ astate->account_sid = dom_sid_dup(astate, r->in.sid);
+ if (astate->account_sid == NULL) {
+ talloc_free(astate);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ astate->account_sid_str = dom_sid_string(astate, astate->account_sid);
+ if (astate->account_sid_str == NULL) {
+ talloc_free(astate);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /* check it really exists */
+ astate->account_name = samdb_search_string(state->sam_ctx, astate,
+ NULL, "sAMAccountName",
+ "objectSid=%s", astate->account_sid_str);
+ if (astate->account_name == NULL) {
+ talloc_free(astate);
+ return NT_STATUS_NO_SUCH_USER;
+ }
+
+ astate->policy = talloc_reference(astate, state);
+ astate->access_mask = r->in.access_mask;
+
+ ah = dcesrv_handle_new(dce_call->conn, LSA_HANDLE_ACCOUNT);
+ if (!ah) {
+ talloc_free(astate);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ah->data = astate;
+ ah->destroy = lsa_Account_destroy;
+
+ *r->out.acct_handle = ah->wire_handle;
+
+ return NT_STATUS_OK;
}