smbd: change flag name from UCF_CREATING_FILE to UCF_PREP_CREATEFILE
[Samba/wip.git] / source4 / winbind / wb_xids2sids.c
blobaeec2ee5be6202da7a15576c4df3f2df734f8b89
1 /*
2 Unix SMB/CIFS implementation.
4 Convet an unixid struct to a SID
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 xids2sids_state {
28 struct composite_context *ctx;
29 struct wbsrv_service *service;
30 struct id_map *ids;
31 int count;
34 struct composite_context *wb_xids2sids_send(TALLOC_CTX *mem_ctx,
35 struct wbsrv_service *service,
36 unsigned int count, struct id_map *ids)
38 struct composite_context *result;
39 struct xids2sids_state *state;
40 struct id_map **pointer_array;
41 unsigned int i;
43 DEBUG(5, ("wb_xids2sids_send called\n"));
45 result = composite_create(mem_ctx, service->task->event_ctx);
46 if (!result) return NULL;
48 state = talloc(mem_ctx, struct xids2sids_state);
49 if (composite_nomem(state, result)) return result;
51 state->ctx = result;
52 result->private_data = state;
53 state->service = service;
54 state->count = count;
55 state->ids = ids;
57 /* We need to convert between calling conventions here - the
58 * values are filled in by reference, so we just need to
59 * provide pointers to them */
60 pointer_array = talloc_array(state, struct id_map *, count+1);
61 if (composite_nomem(pointer_array, result)) return result;
63 for (i=0; i < count; i++) {
64 pointer_array[i] = &ids[i];
66 pointer_array[i] = NULL;
68 state->ctx->status = idmap_xids_to_sids(service->idmap_ctx, mem_ctx,
69 pointer_array);
70 if (!composite_is_ok(state->ctx)) return result;
72 composite_done(state->ctx);
73 return result;
76 NTSTATUS wb_xids2sids_recv(struct composite_context *ctx,
77 struct id_map **ids)
79 NTSTATUS status = composite_wait(ctx);
80 struct xids2sids_state *state = talloc_get_type(ctx->private_data,
81 struct xids2sids_state);
83 DEBUG(5, ("wb_xids2sids_recv called.\n"));
85 /* We don't have to mess with pointer_array on the way out, as
86 * the results are filled into the pointers the caller
87 * supplied */
88 *ids = state->ids;
90 talloc_free(ctx);
91 return status;