wb-ndr: change winbindd_uid2sid_async() to use winbind_get_idmap()
authorStefan Metzmacher <metze@sernet.de>
Tue, 11 Dec 2007 10:51:33 +0000 (11:51 +0100)
committerStefan Metzmacher <metze@sernet.de>
Fri, 2 May 2008 14:12:40 +0000 (16:12 +0200)
metze

source/winbindd/winbindd_idmap.c

index c64566f937bced0caa3f72292df9c98871ea308b..f78bde22c52e2e86e79da7264e73421aaec898ec 100644 (file)
@@ -475,42 +475,70 @@ nomem:
        return;
 }
 
-/* The following uid2sid/gid2sid functions has been contributed by
- * Keith Reynolds <Keith.Reynolds@centrify.com> */
-
 static void winbindd_uid2sid_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 uid2sid\n"));
-               cont(private_data, False, NULL);
+               DEBUG(5, ("Could not get_idmap(uid2sid)\n"));
+               TALLOC_FREE(r);
+               cont(private_data, false, NULL);
                return;
        }
 
-       if (response->result != WINBINDD_OK) {
-               DEBUG(5, ("uid2sid returned an error\n"));
-               cont(private_data, False, NULL);
+       if (r->out.result != WINBIND_STATUS_OK) {
+               DEBUG(5, ("get_idmap(uid2sid) returned an error:0x%08X\n",
+                       r->out.result));
+               TALLOC_FREE(r);
+               cont(private_data, false, NULL);
                return;
        }
 
-       cont(private_data, True, response->data.sid.sid);
+       sid = dom_sid_string(mem_ctx, r->out.rep->sid);
+       if (!sid) {
+               TALLOC_FREE(r);
+               cont(private_data, false, NULL);
+               return;
+       }
+
+       TALLOC_FREE(r);
+       cont(private_data, true, sid);
 }
 
 void winbindd_uid2sid_async(TALLOC_CTX *mem_ctx, uid_t uid,
                            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_UID2SID;
-       request.data.uid = uid;
-       do_async(mem_ctx, idmap_child(), &request, winbindd_uid2sid_recv,
-                (void *)cont, private_data);
+       DEBUG(7,("winbindd_uid2sid_async: Resolving %u to a sid\n",
+               uid));
+
+       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_UID_TO_SID;
+       r->in.req.uid   = uid;
+
+       do_async_ndr(mem_ctx, idmap_child(),
+                    NDR_WINBIND_GET_IDMAP, r,
+                    winbindd_uid2sid_recv, r,
+                    (void *)cont, private_data);
+       return;
+nomem:
+       TALLOC_FREE(r);
+       cont(private_data, false, NULL);
+       return;
 }
 
 enum winbindd_result winbindd_dual_uid2sid(struct winbindd_domain *domain,