r10396: fix build breakage after an incomplete merge from 3.0
[Samba.git] / source / rpcclient / cmd_ds.c
blob0a1fd7e012ba19515e846ed9a3946134cc540906
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Gerald Carter 2002
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
23 #include "rpcclient.h"
25 /* Look up domain related information on a remote host */
27 static NTSTATUS cmd_ds_dsrole_getprimarydominfo(struct cli_state *cli,
28 TALLOC_CTX *mem_ctx, int argc,
29 const char **argv)
31 NTSTATUS result;
32 DS_DOMINFO_CTR ctr;
34 result = cli_ds_getprimarydominfo( cli, mem_ctx, DsRolePrimaryDomainInfoBasic, &ctr );
35 if ( NT_STATUS_IS_OK(result) )
37 printf ("Machine Role = [%d]\n", ctr.basic->machine_role);
39 if ( ctr.basic->flags & DSROLE_PRIMARY_DS_RUNNING ) {
40 printf( "Directory Service is running.\n");
41 printf( "Domain is in %s mode.\n", (ctr.basic->flags & DSROLE_PRIMARY_DS_MIXED_MODE) ? "mixed" : "native" );
43 else
44 printf( "Directory Service not running on server\n");
47 return result;
50 static NTSTATUS cmd_ds_enum_domain_trusts(struct cli_state *cli,
51 TALLOC_CTX *mem_ctx, int argc,
52 const char **argv)
54 NTSTATUS result;
55 uint32 flags = 0x1;
56 struct ds_domain_trust *trusts = NULL;
57 unsigned int num_domains = 0;
58 int i;
60 result = cli_ds_enum_domain_trusts( cli, mem_ctx, cli->desthost, flags,
61 &trusts, &num_domains );
63 printf( "%d domains returned\n", num_domains );
65 for (i=0; i<num_domains; i++ )
66 printf("%s (%s)\n", trusts[i].dns_domain, trusts[i].netbios_domain);
68 return result;
71 /* List of commands exported by this module */
73 struct cmd_set ds_commands[] = {
75 { "LSARPC-DS" },
77 { "dsroledominfo", RPC_RTYPE_NTSTATUS, cmd_ds_dsrole_getprimarydominfo, NULL, PI_LSARPC_DS, "Get Primary Domain Information", "" },
78 { "dsenumdomtrusts", RPC_RTYPE_NTSTATUS, cmd_ds_enum_domain_trusts, NULL, PI_NETLOGON, "Enumerate all trusted domains in an AD forest", "" },
80 { NULL }