wb-ndr: change winbindd_gid2sid_async() to use winbind_get_idmap()
authorStefan Metzmacher <metze@sernet.de>
Tue, 11 Dec 2007 13:26:53 +0000 (14:26 +0100)
committerStefan Metzmacher <metze@sernet.de>
Fri, 2 May 2008 14:12:41 +0000 (16:12 +0200)
metze

source/winbindd/winbindd_idmap.c

index c2582170695d46bf1ee838dd58fda9a7c502de76..d7338f2a5f5a36f39024aa08e6dc22f45f07b4a2 100644 (file)
@@ -542,38 +542,69 @@ nomem:
 }
 
 static void winbindd_gid2sid_recv(TALLOC_CTX *mem_ctx, bool success,
-                                 struct winbindd_response *response,
-                                 void *c, void *private_data)
+                                 struct winbindd_ndr_call *c,
+                                 void *_r,
+                                 void *_cont,
+                                 void *private_data)
 {
        void (*cont)(void *priv, bool succ, const char *sid) =
-               (void (*)(void *, bool, const char *))c;
+               (void (*)(void *, bool, const char *))_cont;
+       struct winbind_get_idmap *r =
+               talloc_get_type_abort(_r, struct winbind_get_idmap);
+       const char *sid;
 
        if (!success) {
-               DEBUG(5, ("Could not trigger gid2sid\n"));
-               cont(private_data, False, NULL);
+               DEBUG(5, ("Could not get_idmap(gid2sid)\n"));
+               TALLOC_FREE(r);
+               cont(private_data, false, NULL);
                return;
        }
 
-       if (response->result != WINBINDD_OK) {
-               DEBUG(5, ("gid2sid returned an error\n"));
-               cont(private_data, False, NULL);
+       if (r->out.result != WINBIND_STATUS_OK) {
+               DEBUG(5, ("get_idmap(gid2sid) returned an error:0x%08X\n",
+                       r->out.result));
+               TALLOC_FREE(r);
+               cont(private_data, false, NULL);
+               return;
+       }
+
+       sid = dom_sid_string(mem_ctx, r->out.rep->sid);
+       if (!sid) {
+               TALLOC_FREE(r);
+               cont(private_data, false, NULL);
                return;
        }
 
-       cont(private_data, True, response->data.sid.sid);
+       TALLOC_FREE(r);
+       cont(private_data, true, sid);
 }
 
 void winbindd_gid2sid_async(TALLOC_CTX *mem_ctx, gid_t gid,
                            void (*cont)(void *private_data, bool success, const char *sid),
                            void *private_data)
 {
-       struct winbindd_request request;
+       struct winbind_get_idmap *r = NULL;
 
-       ZERO_STRUCT(request);
-       request.cmd = WINBINDD_DUAL_GID2SID;
-       request.data.gid = gid;
-       do_async(mem_ctx, idmap_child(), &request, winbindd_gid2sid_recv,
-                (void *)cont, private_data);
+       DEBUG(7,("winbindd_gid2sid_async: Resolving %u to a sid\n",
+               gid));
+
+       r = TALLOC_P(mem_ctx, struct winbind_get_idmap);
+       if (!r) goto nomem;
+       r->in.level = TALLOC_P(r, enum winbind_get_idmap_level);
+       if (!r->in.level) goto nomem;
+
+       *r->in.level    = WINBIND_IDMAP_LEVEL_GID_TO_SID;
+       r->in.req.gid   = gid;
+
+       do_async_ndr(mem_ctx, idmap_child(),
+                    NDR_WINBIND_GET_IDMAP, r,
+                    winbindd_gid2sid_recv, r,
+                    (void *)cont, private_data);
+       return;
+nomem:
+       TALLOC_FREE(r);
+       cont(private_data, false, NULL);
+       return;
 }
 
 enum winbindd_result winbindd_dual_gid2sid(struct winbindd_domain *domain,