diff options
author | Günther Deschner <gd@samba.org> | 2008-04-08 18:43:51 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-04-08 19:40:47 +0200 |
commit | 05202a5d4ef3326db3d43feff2bef5271850296b (patch) | |
tree | 6e8f36fe93ec54df4ae075c7f1403de47e4f758c /source3/lib/netapi/getdc.c | |
parent | 02e90acea7f21ed2b62a15d223c07c9b25c50d08 (diff) | |
download | samba-05202a5d4ef3326db3d43feff2bef5271850296b.tar.gz samba-05202a5d4ef3326db3d43feff2bef5271850296b.tar.bz2 samba-05202a5d4ef3326db3d43feff2bef5271850296b.zip |
Add DsGetDcName call to libnetapi library.
Guenther
(This used to be commit 27780e984152e38c8f80e1c67ddf13b73a2b220d)
Diffstat (limited to 'source3/lib/netapi/getdc.c')
-rw-r--r-- | source3/lib/netapi/getdc.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index f6a666d70d..9ad935efd8 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -133,3 +133,79 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx, return werr; } + +/******************************************************************** +********************************************************************/ + +WERROR DsGetDcName_l(struct libnetapi_ctx *ctx, + struct DsGetDcName *r) +{ + NTSTATUS status; + + status = dsgetdcname(ctx, + r->in.domain_name, + r->in.domain_guid, + r->in.site_name, + r->in.flags, + (struct netr_DsRGetDCNameInfo **)r->out.dc_info); + if (!NT_STATUS_IS_OK(status)) { + libnetapi_set_error_string(ctx, + "failed to find DC: %s", + get_friendly_nt_error_msg(status)); + } + + return ntstatus_to_werror(status); +} + +/******************************************************************** +********************************************************************/ + +WERROR DsGetDcName_r(struct libnetapi_ctx *ctx, + struct DsGetDcName *r) +{ + WERROR werr; + NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; + struct cli_state *cli = NULL; + struct rpc_pipe_client *pipe_cli = NULL; + + status = cli_full_connection(&cli, NULL, r->in.server_name, + NULL, 0, + "IPC$", "IPC", + ctx->username, + ctx->workgroup, + ctx->password, + 0, Undefined, NULL); + + if (!NT_STATUS_IS_OK(status)) { + werr = ntstatus_to_werror(status); + goto done; + } + + pipe_cli = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON, + &status); + if (!pipe_cli) { + werr = ntstatus_to_werror(status); + goto done; + } + + status = rpccli_netr_DsRGetDCName(pipe_cli, + ctx, + r->in.server_name, + r->in.domain_name, + r->in.domain_guid, + NULL, + r->in.flags, + (struct netr_DsRGetDCNameInfo **)r->out.dc_info, + &werr); + if (!NT_STATUS_IS_OK(status)) { + werr = ntstatus_to_werror(status); + goto done; + } + + done: + if (cli) { + cli_shutdown(cli); + } + + return werr; +} |