[SCM] Samba Shared Repository - branch master updated -
4be8d9cca011cc090e19b2b43b59455d7e6a4b89
Günther Deschner
gd at samba.org
Tue Nov 18 15:01:54 GMT 2008
The branch, master has been updated
via 4be8d9cca011cc090e19b2b43b59455d7e6a4b89 (commit)
via b8fee9d863054e18e5103fa197acbf58129db09d (commit)
via ee81191d5c0a6d220b162b8f555a01e6667fbff8 (commit)
from 2ac4b434302ad5e9c105a709fe02431f17a0fecc (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 4be8d9cca011cc090e19b2b43b59455d7e6a4b89
Author: Günther Deschner <gd at samba.org>
Date: Tue Nov 11 19:00:26 2008 +0100
s3-net: use net_scan_dc in net rpc vampire keytab.
Guenther
commit b8fee9d863054e18e5103fa197acbf58129db09d
Author: Günther Deschner <gd at samba.org>
Date: Tue Nov 11 18:59:57 2008 +0100
s3-net: add net_scan_dc function.
Guenther
commit ee81191d5c0a6d220b162b8f555a01e6667fbff8
Author: Günther Deschner <gd at samba.org>
Date: Tue Nov 11 18:59:21 2008 +0100
s3-net: add net_dc_info struct.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source3/utils/net.h | 10 ++++++++++
source3/utils/net_proto.h | 4 ++++
source3/utils/net_rpc_samsync.c | 35 +++++++++++++++++++++++++++--------
source3/utils/net_util.c | 38 ++++++++++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+), 8 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/utils/net.h b/source3/utils/net.h
index 5dc2b11..2d72756 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -70,6 +70,16 @@ struct net_context {
void *private_data;
};
+struct net_dc_info {
+ bool is_dc;
+ bool is_pdc;
+ bool is_ad;
+ bool is_mixed_mode;
+ const char *netbios_domain_name;
+ const char *dns_domain_name;
+ const char *forest_name;
+};
+
#define NET_TRANSPORT_LOCAL 0x01
#define NET_TRANSPORT_RAP 0x02
#define NET_TRANSPORT_RPC 0x04
diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h
index ee4388f..128f88b 100644
--- a/source3/utils/net_proto.h
+++ b/source3/utils/net_proto.h
@@ -473,6 +473,10 @@ void net_display_usage_from_functable(struct functable *table);
const char *net_share_type_str(int num_type);
+NTSTATUS net_scan_dc(struct net_context *c,
+ struct cli_state *cli,
+ struct net_dc_info *dc_info);
+
/* The following definitions come from utils/netlookup.c */
NTSTATUS net_lookup_name_from_sid(struct net_context *c,
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index 9fab949..22c6d25 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -457,6 +457,9 @@ static NTSTATUS rpc_vampire_keytab_ds_internals(struct net_context *c,
int rpc_vampire_keytab(struct net_context *c, int argc, const char **argv)
{
int ret = 0;
+ NTSTATUS status;
+ struct cli_state *cli = NULL;
+ struct net_dc_info dc_info;
if (c->display_usage || (argc < 1)) {
d_printf("Usage:\n"
@@ -465,14 +468,30 @@ int rpc_vampire_keytab(struct net_context *c, int argc, const char **argv)
return 0;
}
- ret = run_rpc_command(c, NULL, &ndr_table_drsuapi.syntax_id,
- NET_FLAGS_SEAL,
- rpc_vampire_keytab_ds_internals, argc, argv);
- if (ret == 0) {
- return 0;
+ status = net_make_ipc_connection(c, 0, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ return -1;
}
- return run_rpc_command(c, NULL, &ndr_table_netlogon.syntax_id, 0,
- rpc_vampire_keytab_internals,
- argc, argv);
+ status = net_scan_dc(c, cli, &dc_info);
+ if (!NT_STATUS_IS_OK(status)) {
+ return -1;
+ }
+
+ if (!dc_info.is_ad) {
+ printf("DC is not running Active Directory\n");
+ return -1;
+ }
+
+ if (dc_info.is_mixed_mode) {
+ ret = run_rpc_command(c, cli, &ndr_table_netlogon.syntax_id,
+ 0,
+ rpc_vampire_keytab_internals, argc, argv);
+ } else {
+ ret = run_rpc_command(c, cli, &ndr_table_drsuapi.syntax_id,
+ NET_FLAGS_SEAL,
+ rpc_vampire_keytab_ds_internals, argc, argv);
+ }
+
+ return ret;
}
diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c
index a9b2bbe..590a916 100644
--- a/source3/utils/net_util.c
+++ b/source3/utils/net_util.c
@@ -607,3 +607,41 @@ const char *net_share_type_str(int num_type)
default: return "Unknown";
}
}
+
+NTSTATUS net_scan_dc(struct net_context *c,
+ struct cli_state *cli,
+ struct net_dc_info *dc_info)
+{
+ TALLOC_CTX *mem_ctx = talloc_tos();
+ struct rpc_pipe_client *dssetup_pipe = NULL;
+ union dssetup_DsRoleInfo info;
+ NTSTATUS status;
+
+ ZERO_STRUCTP(dc_info);
+
+ status = cli_rpc_pipe_open_noauth(cli, &ndr_table_dssetup.syntax_id,
+ &dssetup_pipe);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ status = rpccli_dssetup_DsRoleGetPrimaryDomainInformation(dssetup_pipe, mem_ctx,
+ DS_ROLE_BASIC_INFORMATION,
+ &info,
+ NULL);
+ TALLOC_FREE(dssetup_pipe);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ dc_info->is_dc = (info.basic.role & (DS_ROLE_PRIMARY_DC|DS_ROLE_BACKUP_DC));
+ dc_info->is_pdc = (info.basic.role & DS_ROLE_PRIMARY_DC);
+ dc_info->is_ad = (info.basic.flags & DS_ROLE_PRIMARY_DS_RUNNING);
+ dc_info->is_mixed_mode = (info.basic.flags & DS_ROLE_PRIMARY_DS_MIXED_MODE);
+ dc_info->netbios_domain_name = talloc_strdup(mem_ctx, info.basic.domain);
+ dc_info->dns_domain_name = talloc_strdup(mem_ctx, info.basic.dns_domain);
+ dc_info->forest_name = talloc_strdup(mem_ctx, info.basic.forest);
+
+ return NT_STATUS_OK;
+}
--
Samba Shared Repository
More information about the samba-cvs
mailing list