summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-01-07 23:05:58 +0100
committerGünther Deschner <gd@samba.org>2008-01-07 23:06:12 +0100
commita8d200893a0a7bfbd5a33a52fbe47c4d14a6ed50 (patch)
tree156cfb8dca9fe0bcad89a8275a8ca6daa9d8e2f4 /source3
parente3ea1e1391a10fb1f4708abab038c0cfc2b86b41 (diff)
downloadsamba-a8d200893a0a7bfbd5a33a52fbe47c4d14a6ed50.tar.gz
samba-a8d200893a0a7bfbd5a33a52fbe47c4d14a6ed50.tar.bz2
samba-a8d200893a0a7bfbd5a33a52fbe47c4d14a6ed50.zip
Refactor our DsGetDcName call a bit (before it will move into libnetapi).
Guenther (This used to be commit 41c129da3d33f9fc2864d360e4b6ec5a72caf2a3)
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/dsgetdcname.c117
1 files changed, 101 insertions, 16 deletions
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index f8089cbd6a..fa6cbe146f 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -4,7 +4,7 @@
DsGetDcname
Copyright (C) Gerald Carter 2006
- Copyright (C) Guenther Deschner 2007
+ Copyright (C) Guenther Deschner 2007-2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -891,28 +891,72 @@ static NTSTATUS DsGetDcName_rediscover(TALLOC_CTX *mem_ctx,
}
/********************************************************************
- DsGetDcName.
+********************************************************************/
- This will be the only public function here.
+NTSTATUS DsGetDcName_remote(TALLOC_CTX *mem_ctx,
+ const char *computer_name,
+ const char *domain_name,
+ struct GUID *domain_guid,
+ const char *site_name,
+ uint32_t flags,
+ struct DS_DOMAIN_CONTROLLER_INFO **info)
+{
+ 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, computer_name,
+ NULL, 0,
+ "IPC$", "IPC",
+ "",
+ "",
+ "",
+ 0, Undefined, NULL);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+
+ pipe_cli = cli_rpc_pipe_open_noauth(cli, PI_NETLOGON,
+ &status);
+ if (!pipe_cli) {
+ goto done;
+ }
+
+ werr = rpccli_netlogon_dsr_getdcname(pipe_cli,
+ mem_ctx,
+ computer_name,
+ domain_name,
+ domain_guid,
+ NULL,
+ flags,
+ info);
+ status = werror_to_ntstatus(werr);
+
+ done:
+ cli_rpc_pipe_close(pipe_cli);
+ if (cli) {
+ cli_shutdown(cli);
+ }
+
+ return status;
+}
+
+/********************************************************************
********************************************************************/
-NTSTATUS DsGetDcName(TALLOC_CTX *mem_ctx,
- const char *computer_name,
- const char *domain_name,
- struct GUID *domain_guid,
- const char *site_name,
- uint32_t flags,
- struct DS_DOMAIN_CONTROLLER_INFO **info)
+NTSTATUS DsGetDcName_local(TALLOC_CTX *mem_ctx,
+ const char *computer_name,
+ const char *domain_name,
+ struct GUID *domain_guid,
+ const char *site_name,
+ uint32_t flags,
+ struct DS_DOMAIN_CONTROLLER_INFO **info)
{
NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
struct DS_DOMAIN_CONTROLLER_INFO *myinfo = NULL;
- DEBUG(10,("DsGetDcName: computer_name: %s, domain_name: %s, "
- "domain_guid: %s, site_name: %s, flags: 0x%08x\n",
- computer_name, domain_name,
- domain_guid ? GUID_string(mem_ctx, domain_guid) : "(null)",
- site_name, flags));
-
*info = NULL;
if (!check_allowed_required_flags(flags)) {
@@ -947,3 +991,44 @@ NTSTATUS DsGetDcName(TALLOC_CTX *mem_ctx,
return status;
}
+
+/********************************************************************
+ DsGetDcName.
+
+ This will be the only public function here.
+********************************************************************/
+
+NTSTATUS DsGetDcName(TALLOC_CTX *mem_ctx,
+ const char *computer_name,
+ const char *domain_name,
+ struct GUID *domain_guid,
+ const char *site_name,
+ uint32_t flags,
+ struct DS_DOMAIN_CONTROLLER_INFO **info)
+{
+ DEBUG(10,("DsGetDcName: computer_name: %s, domain_name: %s, "
+ "domain_guid: %s, site_name: %s, flags: 0x%08x\n",
+ computer_name, domain_name,
+ domain_guid ? GUID_string(mem_ctx, domain_guid) : "(null)",
+ site_name, flags));
+
+ *info = NULL;
+
+ if (computer_name) {
+ return DsGetDcName_remote(mem_ctx,
+ computer_name,
+ domain_name,
+ domain_guid,
+ site_name,
+ flags,
+ info);
+ }
+
+ return DsGetDcName_local(mem_ctx,
+ computer_name,
+ domain_name,
+ domain_guid,
+ site_name,
+ flags,
+ info);
+}