diff options
author | Volker Lendecke <vlendec@samba.org> | 2004-12-26 23:31:19 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:07:39 -0500 |
commit | f0d3e9de7e06f32a152d2984c31afd75cdb3abe9 (patch) | |
tree | b1800264f7789c499a72bd0a33e70a30b229a103 /source4/rpc_server | |
parent | b0e6ce645a433c8972eb131cbc4cf0aed3ce1055 (diff) | |
download | samba-f0d3e9de7e06f32a152d2984c31afd75cdb3abe9.tar.gz samba-f0d3e9de7e06f32a152d2984c31afd75cdb3abe9.tar.bz2 samba-f0d3e9de7e06f32a152d2984c31afd75cdb3abe9.zip |
r4372: Implement samr_LookupRids
(This used to be commit 1bab3254f6a27144c6f76edf66573f7fa25b3173)
Diffstat (limited to 'source4/rpc_server')
-rw-r--r-- | source4/rpc_server/samr/dcesrv_samr.c | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c index 5cd40184df..9120bfe468 100644 --- a/source4/rpc_server/samr/dcesrv_samr.c +++ b/source4/rpc_server/samr/dcesrv_samr.c @@ -1065,7 +1065,73 @@ static NTSTATUS samr_LookupNames(struct dcesrv_call_state *dce_call, TALLOC_CTX static NTSTATUS samr_LookupRids(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct samr_LookupRids *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + struct dcesrv_handle *h; + struct samr_domain_state *d_state; + int i; + NTSTATUS status = NT_STATUS_OK; + + ZERO_STRUCT(r->out.names); + ZERO_STRUCT(r->out.types); + + DCESRV_PULL_HANDLE(h, r->in.domain_handle, SAMR_HANDLE_DOMAIN); + + d_state = h->data; + + if (r->in.num_rids == 0) + return NT_STATUS_OK; + + r->out.names.names = talloc_array_p(mem_ctx, struct samr_String, + r->in.num_rids); + if (r->out.names.names == NULL) + return NT_STATUS_NO_MEMORY; + + r->out.types.ids = talloc_array_p(mem_ctx, uint32_t, r->in.num_rids); + if (r->out.types.ids == NULL) + return NT_STATUS_NO_MEMORY; + + r->out.names.count = r->in.num_rids; + r->out.types.count = r->in.num_rids; + + for (i=0; i<r->in.num_rids; i++) { + struct ldb_message **res; + int count; + const char * const attrs[] = { "sAMAccountType", + "sAMAccountName", NULL }; + struct samr_String *str; + uint32_t atype; + + str = &r->out.names.names[i]; + + ZERO_STRUCTP(str); + r->out.types.ids[i] = 0; + + count = samdb_search(d_state->sam_ctx, mem_ctx, + d_state->domain_dn, &res, attrs, + "(objectSid=%s-%u)", d_state->domain_sid, + r->in.rids[i]); + if (count != 1) { + status = STATUS_SOME_UNMAPPED; + continue; + } + + str->string = samdb_result_string(res[0], "sAMAccountName", + NULL); + + atype = samdb_result_uint(res[0], "sAMAccountType", 0); + if (atype == 0) { + status = STATUS_SOME_UNMAPPED; + continue; + } + + r->out.types.ids[i] = samdb_atype_map(atype); + + if (r->out.types.ids[i] == SID_NAME_UNKNOWN) { + status = STATUS_SOME_UNMAPPED; + continue; + } + } + + return status; } |