Converted to call lib/wins_srv.c:wins_srv_ip() instead of lp_wins_server()
[Samba.git] / source3 / rpcclient / cmd_srvsvc.c
blobe1d95af381f5f3e0507784b26fe3c9b0a64f4396
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 NT Domain Authentication SMB / MSRPC client
5 Copyright (C) Andrew Tridgell 1994-1997
6 Copyright (C) Luke Kenneth Casson Leighton 1996-1997
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 2 of the License, or
11 (at your option) any later version.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifdef SYSLOG
26 #undef SYSLOG
27 #endif
29 #include "includes.h"
31 extern int DEBUGLEVEL;
33 #define DEBUG_TESTING
35 extern struct cli_state *smb_cli;
37 extern FILE* out_hnd;
40 /****************************************************************************
41 server get info query
42 ****************************************************************************/
43 void cmd_srv_query_info(struct client_info *info)
45 fstring dest_srv;
46 fstring tmp;
47 SRV_INFO_CTR ctr;
48 uint32 info_level = 101;
50 BOOL res = True;
52 memset((char *)&ctr, '\0', sizeof(ctr));
54 fstrcpy(dest_srv, "\\\\");
55 fstrcat(dest_srv, info->dest_host);
56 strupper(dest_srv);
58 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
60 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
63 DEBUG(4,("cmd_srv_query_info: server:%s info level: %d\n",
64 dest_srv, (int)info_level));
66 DEBUG(5, ("cmd_srv_query_info: smb_cli->fd:%d\n", smb_cli->fd));
68 /* open LSARPC session. */
69 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
71 /* send info level: receive requested info. hopefully. */
72 res = res ? do_srv_net_srv_get_info(smb_cli,
73 dest_srv, info_level, &ctr) : False;
75 /* close the session */
76 cli_nt_session_close(smb_cli);
78 if (res)
80 DEBUG(5,("cmd_srv_query_info: query succeeded\n"));
82 display_srv_info_ctr(out_hnd, ACTION_HEADER , &ctr);
83 display_srv_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
84 display_srv_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
86 else
88 DEBUG(5,("cmd_srv_query_info: query failed\n"));
92 /****************************************************************************
93 server enum connections
94 ****************************************************************************/
95 void cmd_srv_enum_conn(struct client_info *info)
97 fstring dest_srv;
98 fstring qual_srv;
99 fstring tmp;
100 SRV_CONN_INFO_CTR ctr;
101 ENUM_HND hnd;
102 uint32 info_level = 0;
104 BOOL res = True;
106 memset((char *)&ctr, '\0', sizeof(ctr));
108 fstrcpy(qual_srv, "\\\\");
109 fstrcat(qual_srv, info->myhostname);
110 strupper(qual_srv);
112 fstrcpy(dest_srv, "\\\\");
113 fstrcat(dest_srv, info->dest_host);
114 strupper(dest_srv);
116 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
118 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
121 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
122 dest_srv, (int)info_level));
124 DEBUG(5, ("cmd_srv_enum_conn: smb_cli->fd:%d\n", smb_cli->fd));
126 /* open srvsvc session. */
127 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
129 hnd.ptr_hnd = 1;
130 hnd.handle = 0;
132 /* enumerate connections on server */
133 res = res ? do_srv_net_srv_conn_enum(smb_cli,
134 dest_srv, qual_srv,
135 info_level, &ctr, 0xffffffff, &hnd) : False;
137 if (res)
139 display_srv_conn_info_ctr(out_hnd, ACTION_HEADER , &ctr);
140 display_srv_conn_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
141 display_srv_conn_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
144 /* close the session */
145 cli_nt_session_close(smb_cli);
147 if (res)
149 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
151 else
153 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
157 /****************************************************************************
158 server enum shares
159 ****************************************************************************/
160 void cmd_srv_enum_shares(struct client_info *info)
162 fstring dest_srv;
163 fstring tmp;
164 SRV_R_NET_SHARE_ENUM r_o;
165 ENUM_HND hnd;
166 uint32 info_level = 1;
168 BOOL res = True;
170 fstrcpy(dest_srv, "\\\\");
171 fstrcat(dest_srv, info->dest_host);
172 strupper(dest_srv);
174 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
176 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
179 DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n",
180 dest_srv, (int)info_level));
182 DEBUG(5, ("cmd_srv_enum_shares: smb_cli->fd:%d\n", smb_cli->fd));
184 /* open srvsvc session. */
185 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
187 hnd.ptr_hnd = 0;
188 hnd.handle = 0;
190 /* enumerate shares_files on server */
191 res = res ? do_srv_net_srv_share_enum(smb_cli,
192 dest_srv,
193 info_level, &r_o, 0xffffffff, &hnd) : False;
195 if (res)
197 display_srv_share_info_ctr(out_hnd, ACTION_HEADER , &r_o.ctr);
198 display_srv_share_info_ctr(out_hnd, ACTION_ENUMERATE, &r_o.ctr);
199 display_srv_share_info_ctr(out_hnd, ACTION_FOOTER , &r_o.ctr);
200 free_srv_r_net_share_enum(&r_o);
203 /* close the session */
204 cli_nt_session_close(smb_cli);
206 if (res)
208 DEBUG(5,("cmd_srv_enum_shares: query succeeded\n"));
210 else
212 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
216 /****************************************************************************
217 server enum sessions
218 ****************************************************************************/
219 void cmd_srv_enum_sess(struct client_info *info)
221 fstring dest_srv;
222 fstring tmp;
223 SRV_SESS_INFO_CTR ctr;
224 ENUM_HND hnd;
225 uint32 info_level = 0;
227 BOOL res = True;
229 memset((char *)&ctr, '\0', sizeof(ctr));
231 fstrcpy(dest_srv, "\\\\");
232 fstrcat(dest_srv, info->dest_host);
233 strupper(dest_srv);
235 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
237 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
240 DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n",
241 dest_srv, (int)info_level));
243 DEBUG(5, ("cmd_srv_enum_sess: smb_cli->fd:%d\n", smb_cli->fd));
245 /* open srvsvc session. */
246 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
248 hnd.ptr_hnd = 1;
249 hnd.handle = 0;
251 /* enumerate sessions on server */
252 res = res ? do_srv_net_srv_sess_enum(smb_cli,
253 dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False;
255 /* close the session */
256 cli_nt_session_close(smb_cli);
258 if (res)
260 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
262 else
264 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
268 /****************************************************************************
269 server enum files
270 ****************************************************************************/
271 void cmd_srv_enum_files(struct client_info *info)
273 fstring dest_srv;
274 fstring tmp;
275 SRV_FILE_INFO_CTR ctr;
276 ENUM_HND hnd;
277 uint32 info_level = 3;
279 BOOL res = True;
281 memset((char *)&ctr, '\0', sizeof(ctr));
283 fstrcpy(dest_srv, "\\\\");
284 fstrcat(dest_srv, info->dest_host);
285 strupper(dest_srv);
287 if (next_token(NULL, tmp, NULL, sizeof(tmp)-1))
289 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
292 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
293 dest_srv, (int)info_level));
295 DEBUG(5, ("cmd_srv_enum_files: smb_cli->fd:%d\n", smb_cli->fd));
297 /* open srvsvc session. */
298 res = res ? cli_nt_session_open(smb_cli, PIPE_SRVSVC) : False;
300 hnd.ptr_hnd = 1;
301 hnd.handle = 0;
303 /* enumerate files on server */
304 res = res ? do_srv_net_srv_file_enum(smb_cli,
305 dest_srv, NULL, info_level, &ctr, 0x1000, &hnd) : False;
308 if (res)
310 display_srv_file_info_ctr(out_hnd, ACTION_HEADER , &ctr);
311 display_srv_file_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr);
312 display_srv_file_info_ctr(out_hnd, ACTION_FOOTER , &ctr);
315 /* close the session */
316 cli_nt_session_close(smb_cli);
318 if (res)
320 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
322 else
324 DEBUG(5,("cmd_srv_enum_files: query failed\n"));