summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-02-01 16:44:06 +0100
committerGünther Deschner <gd@samba.org>2011-02-01 17:48:40 +0100
commit753094d5d2525ef738939cae4362fc12f882f60b (patch)
treeceb016b166de976a44635bd3a08fa457c73c052e /source3/utils
parent600ff3a74e0a69ee0c239f324a5a32dd4ec14546 (diff)
downloadsamba-753094d5d2525ef738939cae4362fc12f882f60b.tar.gz
samba-753094d5d2525ef738939cae4362fc12f882f60b.tar.bz2
samba-753094d5d2525ef738939cae4362fc12f882f60b.zip
s3-net: add net_scan_dc non-ad variant.
Guenther Autobuild-User: Günther Deschner <gd@samba.org> Autobuild-Date: Tue Feb 1 17:48:40 CET 2011 on sn-devel-104
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_util.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c
index 98d6138d2d..d12a2b9538 100644
--- a/source3/utils/net_util.c
+++ b/source3/utils/net_util.c
@@ -621,6 +621,70 @@ const char *net_share_type_str(int num_type)
}
}
+static NTSTATUS net_scan_dc_noad(struct net_context *c,
+ struct cli_state *cli,
+ struct net_dc_info *dc_info)
+{
+ TALLOC_CTX *mem_ctx = talloc_tos();
+ struct rpc_pipe_client *pipe_hnd = NULL;
+ struct dcerpc_binding_handle *b;
+ NTSTATUS status, result;
+ struct policy_handle pol;
+ union lsa_PolicyInformation *info;
+
+ ZERO_STRUCTP(dc_info);
+ ZERO_STRUCT(pol);
+
+ status = cli_rpc_pipe_open_noauth(cli, &ndr_table_lsarpc.syntax_id,
+ &pipe_hnd);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ b = pipe_hnd->binding_handle;
+
+ status = dcerpc_lsa_open_policy(b, mem_ctx,
+ false,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &pol,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
+ status = result;
+ goto done;
+ }
+
+ status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
+ &pol,
+ LSA_POLICY_INFO_ACCOUNT_DOMAIN,
+ &info,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto done;
+ }
+ if (!NT_STATUS_IS_OK(result)) {
+ status = result;
+ goto done;
+ }
+
+ dc_info->netbios_domain_name = talloc_strdup(mem_ctx, info->account_domain.name.string);
+ if (dc_info->netbios_domain_name == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ done:
+ if (is_valid_policy_hnd(&pol)) {
+ dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
+ }
+
+ TALLOC_FREE(pipe_hnd);
+
+ return status;
+}
+
NTSTATUS net_scan_dc(struct net_context *c,
struct cli_state *cli,
struct net_dc_info *dc_info)
@@ -637,7 +701,9 @@ NTSTATUS net_scan_dc(struct net_context *c,
status = cli_rpc_pipe_open_noauth(cli, &ndr_table_dssetup.syntax_id,
&dssetup_pipe);
if (!NT_STATUS_IS_OK(status)) {
- return status;
+ DEBUG(10,("net_scan_dc: failed to open dssetup pipe with %s, "
+ "retrying with lsa pipe\n", nt_errstr(status)));
+ return net_scan_dc_noad(c, cli, dc_info);
}
dssetup_handle = dssetup_pipe->binding_handle;