s4-smb: Migrate named_pipe_server to tsocket.
[Samba/ekacnet.git] / source4 / winbind / wb_sids2xids.c
blob617318ce52480a4b7d15ae533f2564d664b91e41
1 /*
2 Unix SMB/CIFS implementation.
4 Map SIDs to unixids.
6 Copyright (C) 2008 Kai Blin
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "libcli/composite/composite.h"
24 #include "winbind/wb_server.h"
25 #include "smbd/service_task.h"
27 struct sids2xids_state {
28 struct composite_context *ctx;
29 struct wbsrv_service *service;
30 struct id_map *ids;
31 int count;
34 struct composite_context *wb_sids2xids_send(TALLOC_CTX *mem_ctx,
35 struct wbsrv_service *service,
36 int count, struct id_map *ids)
38 struct composite_context *result;
39 struct sids2xids_state *state;
41 DEBUG(5, ("wb_sids2xids_send called\n"));
43 result = composite_create(mem_ctx, service->task->event_ctx);
44 if (!result) return NULL;
46 state = talloc(result, struct sids2xids_state);
47 if (composite_nomem(state, result)) return result;
49 state->ctx = result;
50 result->private_data = state;
51 state->service = service;
52 state->count = count;
53 state->ids = ids;
55 state->ctx->status = idmap_sids_to_xids(service->idmap_ctx, mem_ctx,
56 count, state->ids);
57 if (!composite_is_ok(state->ctx)) return result;
59 composite_done(state->ctx);
60 return result;
63 NTSTATUS wb_sids2xids_recv(struct composite_context *ctx,
64 struct id_map **ids)
66 NTSTATUS status = composite_wait(ctx);
67 struct sids2xids_state *state = talloc_get_type(ctx->private_data,
68 struct sids2xids_state);
70 DEBUG(5, ("wb_sids2xids_recv called\n"));
72 *ids = state->ids;
74 talloc_free(ctx);
75 return status;