00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "includes.h"
00023 #include "rpcclient.h"
00024
00025
00026
00027 static NTSTATUS cmd_ds_dsrole_getprimarydominfo(struct rpc_pipe_client *cli,
00028 TALLOC_CTX *mem_ctx, int argc,
00029 const char **argv)
00030 {
00031 NTSTATUS result;
00032 DS_DOMINFO_CTR ctr;
00033
00034 result = rpccli_ds_getprimarydominfo( cli, mem_ctx, DsRolePrimaryDomainInfoBasic, &ctr );
00035 if ( NT_STATUS_IS_OK(result) )
00036 {
00037 printf ("Machine Role = [%d]\n", ctr.basic->machine_role);
00038
00039 if ( ctr.basic->flags & DSROLE_PRIMARY_DS_RUNNING ) {
00040 printf( "Directory Service is running.\n");
00041 printf( "Domain is in %s mode.\n", (ctr.basic->flags & DSROLE_PRIMARY_DS_MIXED_MODE) ? "mixed" : "native" );
00042 }
00043 else
00044 printf( "Directory Service not running on server\n");
00045 }
00046
00047 return result;
00048 }
00049
00050 static NTSTATUS cmd_ds_enum_domain_trusts(struct rpc_pipe_client *cli,
00051 TALLOC_CTX *mem_ctx, int argc,
00052 const char **argv)
00053 {
00054 NTSTATUS result;
00055 uint32 flags = DS_DOMAIN_IN_FOREST;
00056 struct ds_domain_trust *trusts = NULL;
00057 unsigned int num_domains = 0;
00058 int i;
00059
00060 if (argc > 1) {
00061 flags = atoi(argv[1]);
00062 }
00063
00064 result = rpccli_ds_enum_domain_trusts( cli, mem_ctx, cli->cli->desthost, flags,
00065 &trusts, &num_domains );
00066
00067 printf( "%d domains returned\n", num_domains );
00068
00069 for (i=0; i<num_domains; i++ )
00070 printf("%s (%s)\n", trusts[i].dns_domain, trusts[i].netbios_domain);
00071
00072 return result;
00073 }
00074
00075
00076
00077 struct cmd_set ds_commands[] = {
00078
00079 { "LSARPC-DS" },
00080
00081 { "dsroledominfo", RPC_RTYPE_NTSTATUS, cmd_ds_dsrole_getprimarydominfo, NULL, PI_LSARPC_DS, NULL, "Get Primary Domain Information", "" },
00082 { "dsenumdomtrusts", RPC_RTYPE_NTSTATUS, cmd_ds_enum_domain_trusts, NULL, PI_NETLOGON, NULL, "Enumerate all trusted domains in an AD forest", "" },
00083
00084 { NULL }
00085 };