summaryrefslogtreecommitdiff
path: root/source4/rpc_server/lsa/dcesrv_lsa.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-11-30 04:34:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:06:14 -0500
commitc33283df20df633ce969ea71bbfb6f62af35fdd9 (patch)
tree072c5584a9a6ec04bdcd27ebef48c04e0ea04ae7 /source4/rpc_server/lsa/dcesrv_lsa.c
parentfdc9f417d89fdf9dd6afbc22843d70585e195c9d (diff)
downloadsamba-c33283df20df633ce969ea71bbfb6f62af35fdd9.tar.gz
samba-c33283df20df633ce969ea71bbfb6f62af35fdd9.tar.bz2
samba-c33283df20df633ce969ea71bbfb6f62af35fdd9.zip
r4012: split out the lsa lookup single name logic into a separate function
(This used to be commit 44d97619623830cc24905a5f4df941d45ebd41c3)
Diffstat (limited to 'source4/rpc_server/lsa/dcesrv_lsa.c')
-rw-r--r--source4/rpc_server/lsa/dcesrv_lsa.c58
1 files changed, 34 insertions, 24 deletions
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index 652a8edf6a..a10f6b1821 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -1025,6 +1025,38 @@ static NTSTATUS lsa_TestCall(struct dcesrv_call_state *dce_call,
}
/*
+ lookup a SID for 1 name
+*/
+static NTSTATUS lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
+ const char *name, struct dom_sid **sid, uint32_t *atype)
+{
+ int ret;
+ struct ldb_message **res;
+ const char * const attrs[] = { "objectSid", "sAMAccountType", NULL};
+
+ ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", name);
+ if (ret == 1) {
+ const char *sid_str = ldb_msg_find_string(res[0], "objectSid", NULL);
+ if (sid_str == NULL) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ *sid = dom_sid_parse_talloc(mem_ctx, sid_str);
+ if (*sid == NULL) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ *atype = samdb_result_uint(res[0], "sAMAccountType", 0);
+
+ return NT_STATUS_OK;
+ }
+
+ /* need to add a call into sidmap to check for a allocated sid */
+
+ return NT_STATUS_INVALID_SID;
+}
+
+/*
lsa_LookupNames2
*/
static NTSTATUS lsa_LookupNames2(struct dcesrv_call_state *dce_call,
@@ -1061,11 +1093,7 @@ static NTSTATUS lsa_LookupNames2(struct dcesrv_call_state *dce_call,
}
for (i=0;i<r->in.num_names;i++) {
- const char * const attrs[] = { "objectSid", "sAMAccountType", NULL};
const char *name = r->in.names[i].string;
- int ret;
- const char *sid_str;
- struct ldb_message **res;
struct dom_sid *sid;
uint32_t atype, rtype, sid_index;
NTSTATUS status2;
@@ -1078,26 +1106,8 @@ static NTSTATUS lsa_LookupNames2(struct dcesrv_call_state *dce_call,
r->out.sids->sids[i].sid_index = 0xFFFFFFFF;
r->out.sids->sids[i].unknown = 0;
- ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", name);
- if (ret != 1) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- sid_str = ldb_msg_find_string(res[0], "objectSid", NULL);
- if (sid_str == NULL) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- sid = dom_sid_parse_talloc(mem_ctx, sid_str);
- if (sid == NULL || sid->num_auths == 0) {
- status = STATUS_SOME_UNMAPPED;
- continue;
- }
-
- atype = samdb_result_uint(res[0], "sAMAccountType", 0);
- if (atype == 0) {
+ status2 = lsa_lookup_name(state, mem_ctx, name, &sid, &atype);
+ if (!NT_STATUS_IS_OK(status) || sid->num_auths == 0) {
status = STATUS_SOME_UNMAPPED;
continue;
}