2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Guenther Deschner 2007
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include "librpc/gen_ndr/libnetapi.h"
23 #include "lib/netapi/netapi.h"
24 #include "lib/netapi/netapi_private.h"
25 #include "lib/netapi/libnetapi.h"
26 #include "libnet/libnet.h"
28 /********************************************************************
29 ********************************************************************/
31 WERROR NetGetDCName_l(struct libnetapi_ctx *ctx,
32 struct NetGetDCName *r)
34 LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetGetDCName);
37 /********************************************************************
38 ********************************************************************/
40 WERROR NetGetDCName_r(struct libnetapi_ctx *ctx,
41 struct NetGetDCName *r)
43 struct cli_state *cli = NULL;
44 struct rpc_pipe_client *pipe_cli = NULL;
48 werr = libnetapi_open_pipe(ctx, r->in.server_name,
49 &ndr_table_netlogon.syntax_id,
52 if (!W_ERROR_IS_OK(werr)) {
56 status = rpccli_netr_GetDcName(pipe_cli, ctx,
59 (const char **)r->out.buffer,
62 if (!NT_STATUS_IS_OK(status)) {
63 werr = ntstatus_to_werror(status);
70 /********************************************************************
71 ********************************************************************/
73 WERROR NetGetAnyDCName_l(struct libnetapi_ctx *ctx,
74 struct NetGetAnyDCName *r)
76 LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetGetAnyDCName);
79 /********************************************************************
80 ********************************************************************/
82 WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx,
83 struct NetGetAnyDCName *r)
85 struct cli_state *cli = NULL;
86 struct rpc_pipe_client *pipe_cli = NULL;
90 werr = libnetapi_open_pipe(ctx, r->in.server_name,
91 &ndr_table_netlogon.syntax_id,
94 if (!W_ERROR_IS_OK(werr)) {
98 status = rpccli_netr_GetAnyDCName(pipe_cli, ctx,
101 (const char **)r->out.buffer,
103 if (!NT_STATUS_IS_OK(status)) {
112 /********************************************************************
113 ********************************************************************/
115 WERROR DsGetDcName_l(struct libnetapi_ctx *ctx,
116 struct DsGetDcName *r)
120 status = dsgetdcname(ctx,
126 (struct netr_DsRGetDCNameInfo **)r->out.dc_info);
127 if (!NT_STATUS_IS_OK(status)) {
128 libnetapi_set_error_string(ctx,
129 "failed to find DC: %s",
130 get_friendly_nt_error_msg(status));
133 return ntstatus_to_werror(status);
136 /********************************************************************
137 ********************************************************************/
139 WERROR DsGetDcName_r(struct libnetapi_ctx *ctx,
140 struct DsGetDcName *r)
143 NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
144 struct cli_state *cli = NULL;
145 struct rpc_pipe_client *pipe_cli = NULL;
147 werr = libnetapi_open_pipe(ctx, r->in.server_name,
148 &ndr_table_netlogon.syntax_id,
151 if (!W_ERROR_IS_OK(werr)) {
155 status = rpccli_netr_DsRGetDCName(pipe_cli,
162 (struct netr_DsRGetDCNameInfo **)r->out.dc_info,
164 if (!NT_STATUS_IS_OK(status)) {
165 werr = ntstatus_to_werror(status);