if we are adding a new sambaAccount, make sure that we add a
[Samba.git] / source / rpcclient / cmd_srvsvc.c
blobd6c1fd544f33692bc5be3d591875a0a5cc181888
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Andrew Tridgell 1992-1999
6 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
7 Copyright (C) Tim Potter 2000
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "includes.h"
25 #include "rpcclient.h"
27 /* Display server query info */
29 static char *get_server_type_str(uint32 type)
31 static fstring typestr;
32 int i;
34 if (type == SV_TYPE_ALL) {
35 fstrcpy(typestr, "All");
36 return typestr;
39 typestr[0] = 0;
41 for (i = 0; i < 32; i++) {
42 if (type & (1 << i)) {
43 switch (1 << i) {
44 case SV_TYPE_WORKSTATION:
45 fstrcat(typestr, "Wk ");
46 break;
47 case SV_TYPE_SERVER:
48 fstrcat(typestr, "Sv ");
49 break;
50 case SV_TYPE_SQLSERVER:
51 fstrcat(typestr, "Sql ");
52 break;
53 case SV_TYPE_DOMAIN_CTRL:
54 fstrcat(typestr, "PDC ");
55 break;
56 case SV_TYPE_DOMAIN_BAKCTRL:
57 fstrcat(typestr, "BDC ");
58 break;
59 case SV_TYPE_TIME_SOURCE:
60 fstrcat(typestr, "Tim ");
61 break;
62 case SV_TYPE_AFP:
63 fstrcat(typestr, "AFP ");
64 break;
65 case SV_TYPE_NOVELL:
66 fstrcat(typestr, "Nov ");
67 break;
68 case SV_TYPE_DOMAIN_MEMBER:
69 fstrcat(typestr, "Dom ");
70 break;
71 case SV_TYPE_PRINTQ_SERVER:
72 fstrcat(typestr, "PrQ ");
73 break;
74 case SV_TYPE_DIALIN_SERVER:
75 fstrcat(typestr, "Din ");
76 break;
77 case SV_TYPE_SERVER_UNIX:
78 fstrcat(typestr, "Unx ");
79 break;
80 case SV_TYPE_NT:
81 fstrcat(typestr, "NT ");
82 break;
83 case SV_TYPE_WFW:
84 fstrcat(typestr, "Wfw ");
85 break;
86 case SV_TYPE_SERVER_MFPN:
87 fstrcat(typestr, "Mfp ");
88 break;
89 case SV_TYPE_SERVER_NT:
90 fstrcat(typestr, "SNT ");
91 break;
92 case SV_TYPE_POTENTIAL_BROWSER:
93 fstrcat(typestr, "PtB ");
94 break;
95 case SV_TYPE_BACKUP_BROWSER:
96 fstrcat(typestr, "BMB ");
97 break;
98 case SV_TYPE_MASTER_BROWSER:
99 fstrcat(typestr, "LMB ");
100 break;
101 case SV_TYPE_DOMAIN_MASTER:
102 fstrcat(typestr, "DMB ");
103 break;
104 case SV_TYPE_SERVER_OSF:
105 fstrcat(typestr, "OSF ");
106 break;
107 case SV_TYPE_SERVER_VMS:
108 fstrcat(typestr, "VMS ");
109 break;
110 case SV_TYPE_WIN95_PLUS:
111 fstrcat(typestr, "W95 ");
112 break;
113 case SV_TYPE_ALTERNATE_XPORT:
114 fstrcat(typestr, "Xpt ");
115 break;
116 case SV_TYPE_LOCAL_LIST_ONLY:
117 fstrcat(typestr, "Dom ");
118 break;
119 case SV_TYPE_DOMAIN_ENUM:
120 fstrcat(typestr, "Loc ");
121 break;
126 i = strlen(typestr) - 1;
128 if (typestr[i] == ' ')
129 typestr[i] = 0;
131 return typestr;
134 static void display_server(char *sname, uint32 type, const char *comment)
136 printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
137 comment);
140 static void display_srv_info_101(SRV_INFO_101 *sv101)
142 fstring name;
143 fstring comment;
145 unistr2_to_unix(name, &sv101->uni_name, sizeof(name) - 1);
146 unistr2_to_unix(comment, &sv101->uni_comment, sizeof(comment) - 1);
148 display_server(name, sv101->srv_type, comment);
150 printf("\tplatform_id :\t%d\n", sv101->platform_id);
151 printf("\tos version :\t%d.%d\n", sv101->ver_major,
152 sv101->ver_minor);
154 printf("\tserver type :\t0x%x\n", sv101->srv_type);
157 static void display_srv_info_102(SRV_INFO_102 *sv102)
159 fstring name;
160 fstring comment;
161 fstring usr_path;
163 unistr2_to_unix(name, &sv102->uni_name, sizeof(name) - 1);
164 unistr2_to_unix(comment, &sv102->uni_comment, sizeof(comment) - 1);
165 unistr2_to_unix(usr_path, &sv102->uni_usr_path, sizeof(usr_path) - 1);
167 display_server(name, sv102->srv_type, comment);
169 printf("\tplatform_id :\t%d\n", sv102->platform_id);
170 printf("\tos version :\t%d.%d\n", sv102->ver_major,
171 sv102->ver_minor);
173 printf("\tusers :\t%x\n", sv102->users);
174 printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden);
175 printf("\tannounce, delta :\t%d, %d\n", sv102->announce,
176 sv102->ann_delta);
177 printf("\tlicenses :\t%d\n", sv102->licenses);
178 printf("\tuser path :\t%s\n", usr_path);
181 /* Server query info */
183 static NTSTATUS cmd_srvsvc_srv_query_info(struct cli_state *cli,
184 TALLOC_CTX *mem_ctx,
185 int argc, char **argv)
187 uint32 info_level = 101;
188 SRV_INFO_CTR ctr;
189 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
191 if (argc > 2) {
192 printf("Usage: %s [infolevel]\n", argv[0]);
193 return NT_STATUS_OK;
196 if (argc == 2)
197 info_level = atoi(argv[1]);
199 result = cli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level,
200 &ctr);
202 if (!NT_STATUS_IS_OK(result)) {
203 goto done;
206 /* Display results */
208 switch (info_level) {
209 case 101:
210 display_srv_info_101(&ctr.srv.sv101);
211 break;
212 case 102:
213 display_srv_info_102(&ctr.srv.sv102);
214 break;
215 default:
216 printf("unsupported info level %d\n", info_level);
217 break;
220 done:
221 return result;
224 /* List of commands exported by this module */
226 struct cmd_set srvsvc_commands[] = {
228 { "SRVSVC" },
230 { "srvinfo", cmd_srvsvc_srv_query_info, PIPE_SRVSVC, "Server query info", "" },
232 { NULL }