do_async_ndr_recv, state);
}
-struct lookupsid_state {
- DOM_SID sid;
- void *caller_private_data;
-};
-
-
-static void lookupsid_recv2(TALLOC_CTX *mem_ctx, bool success,
- struct winbindd_response *response,
- void *c, void *private_data)
+static void winbindd_lookupsid_recv2(TALLOC_CTX *mem_ctx, bool success,
+ struct winbindd_ndr_call *c,
+ void *_private_data,
+ void *_cont,
+ void *cont_private)
{
void (*cont)(void *priv, bool succ, const char *dom_name,
const char *name, enum lsa_SidType type) =
(void (*)(void *, bool, const char *, const char *,
- enum lsa_SidType))c;
- struct lookupsid_state *s = talloc_get_type_abort(private_data,
- struct lookupsid_state);
+ enum lsa_SidType))_cont;
+ struct winbind_lookup *r =
+ talloc_get_type_abort(_private_data, struct winbind_lookup);
if (!success) {
- DEBUG(5, ("Could not trigger lookupsid\n"));
- cont(s->caller_private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
+ DEBUG(5, ("Could not trigger lookup(sid2name)\n"));
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, NULL, SID_NAME_UNKNOWN);
return;
}
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("lookupsid (forest root) returned an error\n"));
- cont(s->caller_private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
+ if (r->out.result != WINBIND_STATUS_OK) {
+ DEBUG(5,("lookup(sid2name) returned an error:0x%08X\n"
+ " (root domain)\n", r->out.result));
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, NULL, SID_NAME_UNKNOWN);
return;
}
- cont(s->caller_private_data, True, response->data.name.dom_name,
- response->data.name.name,
- (enum lsa_SidType)response->data.name.type);
+ cont(cont_private, true,
+ r->out.rep->name_info.domain_name,
+ r->out.rep->name_info.account_name,
+ r->out.rep->name_info.type);
}
-static void lookupsid_recv(TALLOC_CTX *mem_ctx, bool success,
- struct winbindd_response *response,
- void *c, void *private_data)
+static void winbindd_lookupsid_recv1(TALLOC_CTX *mem_ctx, bool success,
+ struct winbindd_ndr_call *c,
+ void *_private_data,
+ void *_cont,
+ void *cont_private)
{
void (*cont)(void *priv, bool succ, const char *dom_name,
const char *name, enum lsa_SidType type) =
(void (*)(void *, bool, const char *, const char *,
- enum lsa_SidType))c;
- struct lookupsid_state *s = talloc_get_type_abort(private_data,
- struct lookupsid_state);
+ enum lsa_SidType))_cont;
+ struct winbind_lookup *r =
+ talloc_get_type_abort(_private_data, struct winbind_lookup);
if (!success) {
- DEBUG(5, ("Could not trigger lookupsid\n"));
- cont(s->caller_private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
+ DEBUG(5, ("Could not trigger lookup(sid2name)\n"));
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, NULL, SID_NAME_UNKNOWN);
return;
}
- if (response->result != WINBINDD_OK) {
- /* Try again using the forest root */
+ if (r->out.result != WINBIND_STATUS_OK) {
struct winbindd_domain *root_domain = find_root_domain();
- struct winbindd_request request;
-
+
if ( !root_domain ) {
- DEBUG(5,("lookupsid_recv: unable to determine forest root\n"));
- cont(s->caller_private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
+ DEBUG(5,("lookup(sid2name) returned an error:0x%08X\n"
+ " (no root domain as fallback)\n", r->out.result));
+
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, NULL, SID_NAME_UNKNOWN);
return;
}
+ DEBUG(5,("lookup(sid2name) returned an error:0x%08X"
+ " (fallback to root domain)\n", r->out.result));
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_LOOKUPSID;
- sid_to_fstring(request.data.sid, &s->sid);
-
- do_async_domain(mem_ctx, root_domain, &request, lookupsid_recv2,
- (void *)cont, s);
-
+ do_async_ndr_domain(mem_ctx, root_domain,
+ NDR_WINBIND_LOOKUP, r,
+ winbindd_lookupsid_recv2, r,
+ (void *)cont, cont_private);
return;
}
- cont(s->caller_private_data, True, response->data.name.dom_name,
- response->data.name.name,
- (enum lsa_SidType)response->data.name.type);
+ cont(cont_private, true,
+ r->out.rep->name_info.domain_name,
+ r->out.rep->name_info.account_name,
+ r->out.rep->name_info.type);
}
void winbindd_lookupsid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
const char *dom_name,
const char *name,
enum lsa_SidType type),
- void *private_data)
+ void *cont_private)
{
struct winbindd_domain *domain;
- struct winbindd_request request;
- struct lookupsid_state *s;
+ struct winbind_lookup *r = NULL;
domain = find_lookup_domain_from_sid(sid);
if (domain == NULL) {
DEBUG(5, ("Could not find domain for sid %s\n",
sid_string_dbg(sid)));
- cont(private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
+ cont(cont_private, false, NULL, NULL, SID_NAME_UNKNOWN);
return;
}
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_LOOKUPSID;
- sid_to_fstring(request.data.sid, sid);
-
- if ( (s = TALLOC_ZERO_P(mem_ctx, struct lookupsid_state)) == NULL ) {
- DEBUG(0, ("winbindd_lookupsid_async: talloc failed\n"));
- cont(private_data, False, NULL, NULL, SID_NAME_UNKNOWN);
- return;
- }
+ r = TALLOC_P(mem_ctx, struct winbind_lookup);
+ if (!r) goto nomem;
+ r->in.level = TALLOC_P(r, enum winbind_lookup_level);
+ if (!r->in.level) goto nomem;
- sid_copy( &s->sid, sid );
- s->caller_private_data = private_data;
+ *r->in.level = WINBIND_LOOKUP_LEVEL_SID2NAME;
+ r->in.req.sid = sid_dup_talloc(r, sid);
+ if (!r->in.req.sid) goto nomem;
- do_async_domain(mem_ctx, domain, &request, lookupsid_recv,
- (void *)cont, s);
+ do_async_ndr_domain(mem_ctx, domain,
+ NDR_WINBIND_LOOKUP, r,
+ winbindd_lookupsid_recv1, r,
+ (void *)cont, cont_private);
+ return;
+nomem:
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, NULL, SID_NAME_UNKNOWN);
+ return;
}
enum winbindd_result winbindd_dual_lookupsid(struct winbindd_domain *domain,