diff options
author | Günther Deschner <gd@samba.org> | 2008-11-11 18:59:57 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-11-18 16:00:52 +0100 |
commit | b8fee9d863054e18e5103fa197acbf58129db09d (patch) | |
tree | fc028ce3d60f1f03c64d577a99c758a9040deff6 /source3/utils | |
parent | ee81191d5c0a6d220b162b8f555a01e6667fbff8 (diff) | |
download | samba-b8fee9d863054e18e5103fa197acbf58129db09d.tar.gz samba-b8fee9d863054e18e5103fa197acbf58129db09d.tar.bz2 samba-b8fee9d863054e18e5103fa197acbf58129db09d.zip |
s3-net: add net_scan_dc function.
Guenther
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_proto.h | 4 | ||||
-rw-r--r-- | source3/utils/net_util.c | 38 |
2 files changed, 42 insertions, 0 deletions
diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h index ee4388f157..128f88b0d3 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_util.c b/source3/utils/net_util.c index a9b2bbe621..590a916522 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; +} |