rpcclient/cmd_ds.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    RPC pipe client
00004 
00005    Copyright (C) Gerald Carter 2002
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011    
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016    
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 
00022 #include "includes.h"
00023 #include "rpcclient.h"
00024 
00025 /* Look up domain related information on a remote host */
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 /* List of commands exported by this module */
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 };

Sambaに対してSat Aug 29 21:23:22 2009に生成されました。  doxygen 1.4.7