2 Unix SMB/CIFS implementation.
4 Winbind daemon - miscellaneous other functions
6 Copyright (C) Tim Potter 2000
7 Copyright (C) Andrew Bartlett 2002
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #define DBGC_CLASS DBGC_WINBIND
30 static const struct winbindd_child_dispatch_table locator_dispatch_table
[];
32 static struct winbindd_child static_locator_child
;
34 void init_locator_child(void)
36 setup_child(&static_locator_child
,
37 locator_dispatch_table
,
38 "log.winbindd", "locator");
41 struct winbindd_child
*locator_child(void)
43 return &static_locator_child
;
46 void winbindd_dsgetdcname(struct winbindd_cli_state
*state
)
48 state
->request
.domain_name
49 [sizeof(state
->request
.domain_name
)-1] = '\0';
51 DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state
->pid
,
52 state
->request
.domain_name
));
54 sendto_child(state
, locator_child());
57 static enum winbindd_result
dual_dsgetdcname(struct winbindd_domain
*domain
,
58 struct winbindd_cli_state
*state
)
61 struct netr_DsRGetDCNameInfo
*info
= NULL
;
62 const char *dc
= NULL
;
64 state
->request
.domain_name
65 [sizeof(state
->request
.domain_name
)-1] = '\0';
67 DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state
->pid
,
68 state
->request
.domain_name
));
70 result
= dsgetdcname(state
->mem_ctx
, winbind_messaging_context(),
71 state
->request
.domain_name
,
72 NULL
, NULL
, state
->request
.flags
, &info
);
74 if (!NT_STATUS_IS_OK(result
)) {
75 return WINBINDD_ERROR
;
78 if (info
->dc_address
) {
79 dc
= strip_hostname(info
->dc_address
);
82 if ((!dc
|| !is_ipaddress_v4(dc
)) && info
->dc_unc
) {
83 dc
= strip_hostname(info
->dc_unc
);
87 return WINBINDD_ERROR
;
90 fstrcpy(state
->response
.data
.dc_name
, dc
);
95 static const struct winbindd_child_dispatch_table locator_dispatch_table
[] = {
97 .name
= "DSGETDCNAME",
98 .struct_cmd
= WINBINDD_DSGETDCNAME
,
99 .struct_fn
= dual_dsgetdcname
,