summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd_allocate_uid.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-08-30 09:41:43 +0200
committerVolker Lendecke <vl@samba.org>2009-08-30 09:48:28 +0200
commit9e7c6f12fdb6a8ce198359572bb9e69c7d46530a (patch)
treeedf18daf2faa581537dc26fa033cdebeeeba50d0 /source3/winbindd/winbindd_allocate_uid.c
parent0d120be36bfc561e3f679d081993ccc6bea2a401 (diff)
downloadsamba-9e7c6f12fdb6a8ce198359572bb9e69c7d46530a.tar.gz
samba-9e7c6f12fdb6a8ce198359572bb9e69c7d46530a.tar.bz2
samba-9e7c6f12fdb6a8ce198359572bb9e69c7d46530a.zip
w3:winbind: Convert WINBINDD_ALLOCATE_UID to the new API
Diffstat (limited to 'source3/winbindd/winbindd_allocate_uid.c')
-rw-r--r--source3/winbindd/winbindd_allocate_uid.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/source3/winbindd/winbindd_allocate_uid.c b/source3/winbindd/winbindd_allocate_uid.c
new file mode 100644
index 0000000000..171d0ccb91
--- /dev/null
+++ b/source3/winbindd/winbindd_allocate_uid.c
@@ -0,0 +1,92 @@
+/*
+ Unix SMB/CIFS implementation.
+ async implementation of WINBINDD_ALLOCATE_UID
+ Copyright (C) Volker Lendecke 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "winbindd.h"
+#include "librpc/gen_ndr/cli_wbint.h"
+
+struct winbindd_allocate_uid_state {
+ uint64_t uid;
+};
+
+static void winbindd_allocate_uid_done(struct tevent_req *subreq);
+
+struct tevent_req *winbindd_allocate_uid_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request)
+{
+ struct tevent_req *req, *subreq;
+ struct winbindd_allocate_uid_state *state;
+ struct winbindd_child *child;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct winbindd_allocate_uid_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ DEBUG(3, ("allocate_uid\n"));
+
+ child = idmap_child();
+
+ subreq = rpccli_wbint_AllocateUid_send(state, ev, child->rpccli,
+ &state->uid);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, winbindd_allocate_uid_done, req);
+ return req;
+}
+
+static void winbindd_allocate_uid_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct winbindd_allocate_uid_state *state = tevent_req_data(
+ req, struct winbindd_allocate_uid_state);
+ NTSTATUS status, result;
+
+ status = rpccli_wbint_AllocateUid_recv(subreq, state, &result);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
+ tevent_req_nterror(req, result);
+ return;
+ }
+ tevent_req_done(req);
+}
+
+NTSTATUS winbindd_allocate_uid_recv(struct tevent_req *req,
+ struct winbindd_response *response)
+{
+ struct winbindd_allocate_uid_state *state = tevent_req_data(
+ req, struct winbindd_allocate_uid_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ DEBUG(5, ("Could not allocate uid: %s\n", nt_errstr(status)));
+ return status;
+ }
+ response->data.uid = state->uid;
+ return NT_STATUS_OK;
+}