wb-ndr: implement winbindd_ndr_domain_child_lookup() TODO!...
authorStefan Metzmacher <metze@sernet.de>
Wed, 23 Jan 2008 13:18:25 +0000 (14:18 +0100)
committerStefan Metzmacher <metze@sernet.de>
Fri, 2 May 2008 14:13:15 +0000 (16:13 +0200)
With levels WINBIND_LOOKUP_LEVEL_SID2NAME WINBIND_LOOKUP_LEVEL_NAME2SID

metze

source/winbindd/winbindd_async.c
source/winbindd/winbindd_domain.c

index 7cc0a22bca46d929b436d52d8136ca123b859e6c..3efaeb295b7f67bb9a237faca78060363700a296 100644 (file)
@@ -357,6 +357,101 @@ enum winbindd_result winbindd_dual_lookupsid(struct winbindd_domain *domain,
        return WINBINDD_OK;
 }
 
+static void ndr_child_lookup_sid2name(struct winbindd_domain *domain,
+                                     struct winbindd_cli_state *state,
+                                     struct winbind_lookup *r)
+{
+       bool ok;
+
+       DEBUG(3, ("lookup sid2name %s\n",
+                 sid_string_dbg(r->in.req.sid)));
+
+       /* Lookup the sid */
+
+       ok = winbindd_lookup_name_by_sid(r, domain,
+                                        r->in.req.sid,
+                                        (char **)&r->out.rep->name_info.domain_name,
+                                        (char **)&r->out.rep->name_info.account_name,
+                                        &r->out.rep->name_info.type);
+       if (!ok) {
+               DEBUG(1, ("Can't lookup name by sid\n"));
+               r->out.result = WINBIND_STATUS_FOOBAR;
+               return;
+       }
+
+       r->out.result = WINBIND_STATUS_OK;
+}
+
+static void ndr_child_lookup_name2sid(struct winbindd_domain *domain,
+                                     struct winbindd_cli_state *state,
+                                     struct winbind_lookup *r)
+{
+       bool ok;
+       char *name_domain;
+       char *name_user;
+       char *p;
+
+       DEBUG(3, ("lookup name2sid %s\n",
+                 r->in.req.name));
+
+       name_domain = talloc_strdup(r, r->in.req.name);
+       if (!name_domain) {
+               r->out.result = WINBIND_STATUS_NO_MEMORY;
+               return;
+       }
+
+       /* the name must be a fully qualified name */
+       p = strstr(name_domain, lp_winbind_separator());
+       if (!p) {
+               r->out.result = WINBIND_STATUS_INVALID_PARAMETER;
+               return;
+       }
+
+       *p = 0;
+       name_user = p+1;
+
+       r->out.rep->sid_info.sid = TALLOC_ZERO_P(r, struct dom_sid);
+       if (!r->out.rep->sid_info.sid) {
+               r->out.result = WINBIND_STATUS_NO_MEMORY;
+               return;
+       }
+
+       /* Lookup name from DC using lsa_lookup_names() */
+/* TODO: */    ok = winbindd_lookup_sid_by_name(state->mem_ctx, WINBINDD_LOOKUPNAME,
+                                        domain, name_domain, name_user,
+                                        r->out.rep->sid_info.sid,
+                                        &r->out.rep->sid_info.type);
+       if (!ok) {
+               DEBUG(1, ("Can't lookup name by sid\n"));
+               r->out.result = WINBIND_STATUS_FOOBAR;
+               return;
+       }
+
+       r->out.result = WINBIND_STATUS_OK;
+}
+
+void winbindd_ndr_domain_child_lookup(struct winbindd_domain *domain,
+                                     struct winbindd_cli_state *state)
+{
+       struct winbind_lookup *r;
+
+       r = talloc_get_type_abort(state->c.ndr.r,
+                                 struct winbind_lookup);
+
+       switch (*r->in.level) {
+       case WINBIND_LOOKUP_LEVEL_SID2NAME:
+               ndr_child_lookup_sid2name(domain, state, r);
+               return;
+
+       case WINBIND_LOOKUP_LEVEL_NAME2SID:
+               ndr_child_lookup_name2sid(domain, state, r);
+               return;
+       }
+
+       r->out.result = WINBIND_STATUS_UNKNOWN_LEVEL;
+       return;
+}
+
 /********************************************************************
  This is the second callback after contacting the forest root
 ********************************************************************/
index 6ef42ce85cdef4f4042319fc7b54d12c7f3bb176..07eab685c5e5f8a3cd70a0884ce827eaf9d4d5cb 100644 (file)
@@ -49,6 +49,10 @@ static const struct winbindd_child_dispatch_table domain_dispatch_table[] = {
                .name           = "LOOKUPRIDS",
                .struct_cmd     = WINBINDD_LOOKUPRIDS,
                .struct_fn      = winbindd_dual_lookuprids,
+       },{
+               .name           = "NDR_WINBIND_LOOKUP",
+               .ndr_opnum      = NDR_WINBIND_LOOKUP,
+               .ndr_fn         = winbindd_ndr_domain_child_lookup,
        },{
                .name           = "LIST_TRUSTDOM",
                .struct_cmd     = WINBINDD_LIST_TRUSTDOM,