s3:winbind: Add async wb_lookupname
[amitay/samba.git] / source3 / winbindd / winbindd_dual_srv.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    In-Child server implementation of the routines defined in wbint.idl
5
6    Copyright (C) Volker Lendecke 2009
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "winbindd/winbindd.h"
24 #include "winbindd/winbindd_proto.h"
25 #include "librpc/gen_ndr/srv_wbint.h"
26
27 void _wbint_Ping(pipes_struct *p, struct wbint_Ping *r)
28 {
29         *r->out.out_data = r->in.in_data;
30 }
31
32 NTSTATUS _wbint_LookupSid(pipes_struct *p, struct wbint_LookupSid *r)
33 {
34         struct winbindd_domain *domain = wb_child_domain();
35         char *dom_name;
36         char *name;
37         enum lsa_SidType type;
38         NTSTATUS status;
39
40         if (domain == NULL) {
41                 return NT_STATUS_REQUEST_NOT_ACCEPTED;
42         }
43
44         status = domain->methods->sid_to_name(domain, p->mem_ctx, r->in.sid,
45                                               &dom_name, &name, &type);
46         if (!NT_STATUS_IS_OK(status)) {
47                 return status;
48         }
49
50         *r->out.domain = dom_name;
51         *r->out.name = name;
52         *r->out.type = type;
53         return NT_STATUS_OK;
54 }
55
56 NTSTATUS _wbint_LookupName(pipes_struct *p, struct wbint_LookupName *r)
57 {
58         struct winbindd_domain *domain = wb_child_domain();
59
60         if (domain == NULL) {
61                 return NT_STATUS_REQUEST_NOT_ACCEPTED;
62         }
63
64         return domain->methods->name_to_sid(
65                 domain, p->mem_ctx, r->in.domain, r->in.name, r->in.flags,
66                 r->out.sid, r->out.type);
67 }