Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 : RPC pipe client
4 :
5 : Copyright (C) Gerald Carter 2002
6 : Copyright (C) Guenther Deschner 2008
7 :
8 : This program is free software; you can redistribute it and/or modify
9 : it under the terms of the GNU General Public License as published by
10 : the Free Software Foundation; either version 3 of the License, or
11 : (at your option) any later version.
12 :
13 : This program is distributed in the hope that it will be useful,
14 : but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : GNU General Public License for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with this program. If not, see <http://www.gnu.org/licenses/>.
20 : */
21 :
22 : #include "includes.h"
23 : #include "rpcclient.h"
24 : #include "../librpc/gen_ndr/ndr_dssetup_c.h"
25 :
26 : /* Look up domain related information on a remote host */
27 :
28 0 : static WERROR cmd_ds_dsrole_getprimarydominfo(struct rpc_pipe_client *cli,
29 : TALLOC_CTX *mem_ctx, int argc,
30 : const char **argv)
31 : {
32 0 : struct dcerpc_binding_handle *b = cli->binding_handle;
33 : NTSTATUS status;
34 : WERROR werr;
35 : union dssetup_DsRoleInfo info;
36 :
37 0 : status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(b, mem_ctx,
38 : DS_ROLE_BASIC_INFORMATION,
39 : &info,
40 : &werr);
41 0 : if (!NT_STATUS_IS_OK(status)) {
42 0 : return ntstatus_to_werror(status);
43 : }
44 :
45 0 : if (!W_ERROR_IS_OK(werr)) {
46 0 : return werr;
47 : }
48 :
49 0 : printf ("Machine Role = [%d]\n", info.basic.role);
50 :
51 0 : if (info.basic.flags & DS_ROLE_PRIMARY_DS_RUNNING) {
52 0 : printf("Directory Service is running.\n");
53 0 : printf("Domain is in %s mode.\n",
54 0 : (info.basic.flags & DS_ROLE_PRIMARY_DS_MIXED_MODE) ? "mixed" : "native" );
55 : } else {
56 0 : printf("Directory Service not running on server\n");
57 : }
58 :
59 0 : return werr;
60 : }
61 :
62 : /* List of commands exported by this module */
63 :
64 : struct cmd_set ds_commands[] = {
65 :
66 : {
67 : .name = "LSARPC-DS"
68 : },
69 :
70 : {
71 : .name = "dsroledominfo",
72 : .returntype = RPC_RTYPE_WERROR,
73 : .ntfn = NULL,
74 : .wfn = cmd_ds_dsrole_getprimarydominfo,
75 : .table = &ndr_table_dssetup,
76 : .rpc_pipe = NULL,
77 : .description = "Get Primary Domain Information",
78 : .usage = ""
79 : },
80 :
81 : {
82 : .name = NULL,
83 : }
84 : };
|