KCC: kcc.my_site_guid was not really used
[Samba.git] / source3 / rpcclient / cmd_clusapi.c
blob280b5a070d2d11c2bc4b6392ec45326546ed8405
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Günther Deschner 2015
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 3 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, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "rpcclient.h"
23 #include "../librpc/gen_ndr/ndr_clusapi_c.h"
25 static WERROR cmd_clusapi_open_cluster(struct rpc_pipe_client *cli,
26 TALLOC_CTX *mem_ctx,
27 int argc,
28 const char **argv)
30 struct dcerpc_binding_handle *b = cli->binding_handle;
31 NTSTATUS status;
32 WERROR error;
33 struct policy_handle Cluster;
35 status = dcerpc_clusapi_OpenCluster(b, mem_ctx,
36 &error,
37 &Cluster);
38 if (!NT_STATUS_IS_OK(status)) {
39 return ntstatus_to_werror(status);
42 if (!W_ERROR_IS_OK(error)) {
43 printf("error: %s\n", win_errstr(error));
44 return error;
47 printf("successfully opened cluster\n");
49 status = dcerpc_clusapi_CloseCluster(b, mem_ctx,
50 &Cluster,
51 &error);
52 if (!NT_STATUS_IS_OK(status)) {
53 return ntstatus_to_werror(status);
56 if (!W_ERROR_IS_OK(error)) {
57 printf("error: %s\n", win_errstr(error));
58 return error;
61 printf("successfully closed cluster\n");
63 return WERR_OK;
66 static WERROR cmd_clusapi_get_cluster_name(struct rpc_pipe_client *cli,
67 TALLOC_CTX *mem_ctx,
68 int argc,
69 const char **argv)
71 struct dcerpc_binding_handle *b = cli->binding_handle;
72 NTSTATUS status;
73 WERROR error;
74 const char *ClusterName;
75 const char *NodeName;
77 status = dcerpc_clusapi_GetClusterName(b, mem_ctx,
78 &ClusterName,
79 &NodeName,
80 &error);
81 if (!NT_STATUS_IS_OK(status)) {
82 return ntstatus_to_werror(status);
85 if (!W_ERROR_IS_OK(error)) {
86 printf("error: %s\n", win_errstr(error));
87 return error;
90 printf("ClusterName: %s\n", ClusterName);
91 printf("NodeName: %s\n", NodeName);
93 return WERR_OK;
96 static WERROR cmd_clusapi_get_cluster_version(struct rpc_pipe_client *cli,
97 TALLOC_CTX *mem_ctx,
98 int argc,
99 const char **argv)
101 struct dcerpc_binding_handle *b = cli->binding_handle;
102 NTSTATUS status;
103 WERROR error;
104 uint16_t lpwMajorVersion;
105 uint16_t lpwMinorVersion;
106 uint16_t lpwBuildNumber;
107 const char *lpszVendorId;
108 const char *lpszCSDVersion;
110 status = dcerpc_clusapi_GetClusterVersion(b, mem_ctx,
111 &lpwMajorVersion,
112 &lpwMinorVersion,
113 &lpwBuildNumber,
114 &lpszVendorId,
115 &lpszCSDVersion,
116 &error);
117 if (!NT_STATUS_IS_OK(status)) {
118 return ntstatus_to_werror(status);
121 if (!W_ERROR_IS_OK(error)) {
122 printf("error: %s\n", win_errstr(error));
123 return error;
126 printf("lpwMajorVersion: %d\n", lpwMajorVersion);
127 printf("lpwMinorVersion: %d\n", lpwMinorVersion);
128 printf("lpwBuildNumber: %d\n", lpwBuildNumber);
129 printf("lpszVendorId: %s\n", lpszVendorId);
130 printf("lpszCSDVersion: %s\n", lpszCSDVersion);
132 return WERR_OK;
135 static WERROR cmd_clusapi_get_quorum_resource(struct rpc_pipe_client *cli,
136 TALLOC_CTX *mem_ctx,
137 int argc,
138 const char **argv)
140 struct dcerpc_binding_handle *b = cli->binding_handle;
141 NTSTATUS status;
142 WERROR error;
143 const char *lpszResourceName;
144 const char *lpszDeviceName;
145 uint32_t pdwMaxQuorumLogSize;
146 WERROR rpc_status;
148 status = dcerpc_clusapi_GetQuorumResource(b, mem_ctx,
149 &lpszResourceName,
150 &lpszDeviceName,
151 &pdwMaxQuorumLogSize,
152 &rpc_status,
153 &error);
154 if (!NT_STATUS_IS_OK(status)) {
155 return ntstatus_to_werror(status);
158 if (!W_ERROR_IS_OK(error)) {
159 printf("error: %s\n", win_errstr(error));
160 return error;
163 printf("lpszResourceName: %s\n", lpszResourceName);
164 printf("lpszDeviceName: %s\n", lpszDeviceName);
165 printf("pdwMaxQuorumLogSize: %d\n", pdwMaxQuorumLogSize);
166 printf("rpc_status: %s\n", win_errstr(rpc_status));
168 return WERR_OK;
171 static WERROR cmd_clusapi_create_enum(struct rpc_pipe_client *cli,
172 TALLOC_CTX *mem_ctx,
173 int argc,
174 const char **argv)
176 struct dcerpc_binding_handle *b = cli->binding_handle;
177 NTSTATUS status;
178 WERROR error;
179 uint32_t dwType = 1;
180 struct ENUM_LIST *ReturnEnum;
181 WERROR rpc_status;
183 if (argc >= 2) {
184 sscanf(argv[1],"%x",&dwType);
187 status = dcerpc_clusapi_CreateEnum(b, mem_ctx,
188 dwType,
189 &ReturnEnum,
190 &rpc_status,
191 &error);
192 if (!NT_STATUS_IS_OK(status)) {
193 return ntstatus_to_werror(status);
196 if (!W_ERROR_IS_OK(error)) {
197 printf("error: %s\n", win_errstr(error));
198 return error;
201 printf("rpc_status: %s\n", win_errstr(rpc_status));
203 return WERR_OK;
206 static WERROR cmd_clusapi_open_resource(struct rpc_pipe_client *cli,
207 TALLOC_CTX *mem_ctx,
208 int argc,
209 const char **argv)
211 struct dcerpc_binding_handle *b = cli->binding_handle;
212 NTSTATUS status;
213 const char *lpszResourceName = "Cluster Name";
214 WERROR Status;
215 struct policy_handle hResource;
216 WERROR rpc_status;
218 if (argc >= 2) {
219 lpszResourceName = argv[1];
222 status = dcerpc_clusapi_OpenResource(b, mem_ctx,
223 lpszResourceName,
224 &Status,
225 &rpc_status,
226 &hResource);
227 if (!NT_STATUS_IS_OK(status)) {
228 return ntstatus_to_werror(status);
231 if (!W_ERROR_IS_OK(Status)) {
232 printf("Status: %s\n", win_errstr(Status));
233 return Status;
236 printf("rpc_status: %s\n", win_errstr(rpc_status));
238 return WERR_OK;
241 struct cmd_set clusapi_commands[] = {
243 { "CLUSAPI" },
244 { "clusapi_open_cluster", RPC_RTYPE_WERROR, NULL, cmd_clusapi_open_cluster, &ndr_table_clusapi, NULL, "bla", "" },
245 { "clusapi_get_cluster_name", RPC_RTYPE_WERROR, NULL, cmd_clusapi_get_cluster_name, &ndr_table_clusapi, NULL, "bla", "" },
246 { "clusapi_get_cluster_version", RPC_RTYPE_WERROR, NULL, cmd_clusapi_get_cluster_version, &ndr_table_clusapi, NULL, "bla", "" },
247 { "clusapi_get_quorum_resource", RPC_RTYPE_WERROR, NULL, cmd_clusapi_get_quorum_resource, &ndr_table_clusapi, NULL, "bla", "" },
248 { "clusapi_create_enum", RPC_RTYPE_WERROR, NULL, cmd_clusapi_create_enum, &ndr_table_clusapi, NULL, "bla", "" },
249 { "clusapi_open_resource", RPC_RTYPE_WERROR, NULL, cmd_clusapi_open_resource, &ndr_table_clusapi, NULL, "bla", "" },
250 { NULL }