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,