This is the second callback after contacting the forest root
********************************************************************/
-struct lookupname_state {
- char *dom_name;
- char *name;
- void *caller_private_data;
-};
-
-
-static void lookupname_recv2(TALLOC_CTX *mem_ctx, bool success,
- struct winbindd_response *response,
- void *c, void *private_data)
+static void winbindd_lookupname_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 DOM_SID *sid,
- enum lsa_SidType type) =
- (void (*)(void *, bool, const DOM_SID *, enum lsa_SidType))c;
- DOM_SID sid;
- struct lookupname_state *s = talloc_get_type_abort( private_data,
- struct lookupname_state );
+ void (*cont)(void *priv, bool succ,
+ const DOM_SID *sid, enum lsa_SidType type) =
+ (void (*)(void *, bool, const DOM_SID *,
+ enum lsa_SidType))_cont;
+ struct winbind_lookup *r =
+ talloc_get_type_abort(_private_data, struct winbind_lookup);
if (!success) {
- DEBUG(5, ("Could not trigger lookup_name\n"));
- cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
- return;
- }
-
- if (response->result != WINBINDD_OK) {
- DEBUG(5, ("lookup_name returned an error\n"));
- cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
+ DEBUG(5, ("Could not trigger lookup(name2sid)\n"));
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, SID_NAME_UNKNOWN);
return;
}
- if (!string_to_sid(&sid, response->data.sid.sid)) {
- DEBUG(0, ("Could not convert string %s to sid\n",
- response->data.sid.sid));
- cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
+ if (r->out.result != WINBIND_STATUS_OK) {
+ DEBUG(5,("lookup(name2sid) returned an error:0x%08X\n"
+ " (root domain)\n", r->out.result));
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, SID_NAME_UNKNOWN);
return;
}
- cont(s->caller_private_data, True, &sid,
- (enum lsa_SidType)response->data.sid.type);
+ cont(cont_private, true,
+ r->out.rep->sid_info.sid,
+ r->out.rep->sid_info.type);
}
/********************************************************************
This is the first callback after contacting our own domain
********************************************************************/
-static void lookupname_recv(TALLOC_CTX *mem_ctx, bool success,
- struct winbindd_response *response,
- void *c, void *private_data)
+static void winbindd_lookupname_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 DOM_SID *sid,
- enum lsa_SidType type) =
- (void (*)(void *, bool, const DOM_SID *, enum lsa_SidType))c;
- DOM_SID sid;
- struct lookupname_state *s = talloc_get_type_abort( private_data,
- struct lookupname_state );
+ void (*cont)(void *priv, bool succ,
+ const DOM_SID *sid, enum lsa_SidType type) =
+ (void (*)(void *, bool, const DOM_SID *,
+ enum lsa_SidType))_cont;
+ struct winbind_lookup *r =
+ talloc_get_type_abort(_private_data, struct winbind_lookup);
if (!success) {
- DEBUG(5, ("lookupname_recv: lookup_name() failed!\n"));
- cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
+ DEBUG(5, ("Could not trigger lookup(name2sid)\n"));
+ TALLOC_FREE(r);
+ cont(cont_private, false, 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,("lookupname_recv: unable to determine forest root\n"));
- cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
+ DEBUG(5,("lookup(name2sid) returned an error:0x%08X\n"
+ " (no root domain as fallback)\n", r->out.result));
+
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, SID_NAME_UNKNOWN);
return;
}
+ DEBUG(5,("lookup(name2sid) returned an error:0x%08X"
+ " (fallback to root domain)\n", r->out.result));
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_LOOKUPNAME;
-
- fstrcpy( request.data.name.dom_name, s->dom_name );
- fstrcpy( request.data.name.name, s->name );
-
- do_async_domain(mem_ctx, root_domain, &request, lookupname_recv2,
- (void *)cont, s);
-
- return;
- }
-
- if (!string_to_sid(&sid, response->data.sid.sid)) {
- DEBUG(0, ("Could not convert string %s to sid\n",
- response->data.sid.sid));
- cont(s->caller_private_data, False, NULL, SID_NAME_UNKNOWN);
+ do_async_ndr_domain(mem_ctx, root_domain,
+ NDR_WINBIND_LOOKUP, r,
+ winbindd_lookupname_recv2, r,
+ (void *)cont, cont_private);
return;
}
- cont(s->caller_private_data, True, &sid,
- (enum lsa_SidType)response->data.sid.type);
+ cont(cont_private, true,
+ r->out.rep->sid_info.sid,
+ r->out.rep->sid_info.type);
}
/********************************************************************
const DOM_SID *sid,
enum lsa_SidType type),
enum winbindd_cmd orig_cmd,
- void *private_data)
+ void *cont_private)
{
- struct winbindd_request request;
struct winbindd_domain *domain;
- struct lookupname_state *s;
+ struct winbind_lookup *r = NULL;
if ( (domain = find_lookup_domain_from_name(dom_name)) == NULL ) {
DEBUG(5, ("Could not find domain for name '%s'\n", dom_name));
- cont(private_data, False, NULL, SID_NAME_UNKNOWN);
+ cont(cont_private, false, NULL, SID_NAME_UNKNOWN);
return;
}
- ZERO_STRUCT(request);
- request.cmd = WINBINDD_LOOKUPNAME;
- request.original_cmd = orig_cmd;
- fstrcpy(request.data.name.dom_name, dom_name);
- fstrcpy(request.data.name.name, name);
-
- if ( (s = TALLOC_ZERO_P(mem_ctx, struct lookupname_state)) == NULL ) {
- DEBUG(0, ("winbindd_lookupname_async: talloc failed\n"));
- cont(private_data, False, NULL, SID_NAME_UNKNOWN);
- return;
- }
-
- s->dom_name = talloc_strdup( s, dom_name );
- s->name = talloc_strdup( s, name );
- if (!s->dom_name || !s->name) {
- cont(private_data, False, NULL, SID_NAME_UNKNOWN);
- return;
- }
-
- s->caller_private_data = private_data;
+ 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;
- do_async_domain(mem_ctx, domain, &request, lookupname_recv,
- (void *)cont, s);
+ *r->in.level = WINBIND_LOOKUP_LEVEL_NAME2SID;
+ r->in.req.name = talloc_asprintf(r, "%s%s%s",
+ dom_name,
+ lp_winbind_separator(),
+ name);
+ if (!r->in.req.name) goto nomem;
+/*TODO: pass down orig_cmd */
+ do_async_ndr_domain(mem_ctx, domain,
+ NDR_WINBIND_LOOKUP, r,
+ winbindd_lookupname_recv1, r,
+ (void *)cont, cont_private);
+ return;
+nomem:
+ TALLOC_FREE(r);
+ cont(cont_private, false, NULL, SID_NAME_UNKNOWN);
+ return;
}
enum winbindd_result winbindd_dual_lookupname(struct winbindd_domain *domain,