rpcclient "Service Control Manager" svcenum [-i] command.
[samba.git] / source / rpcclient / cmd_wkssvc.c
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
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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23
24
25 #ifdef SYSLOG
26 #undef SYSLOG
27 #endif
28
29 #include "includes.h"
30 #include "nterr.h"
31
32 extern int DEBUGLEVEL;
33
34 #define DEBUG_TESTING
35
36 extern struct cli_state *smb_cli;
37
38 extern FILE* out_hnd;
39
40
41 /****************************************************************************
42 workstation get info query
43 ****************************************************************************/
44 void cmd_wks_query_info(struct client_info *info)
45 {
46         uint16 nt_pipe_fnum;
47         fstring dest_wks;
48         fstring tmp;
49         WKS_INFO_100 ctr;
50         uint32 info_level = 100;
51
52         BOOL res = True;
53
54         bzero(&ctr, sizeof(ctr));
55
56         fstrcpy(dest_wks, "\\\\");
57         fstrcat(dest_wks, info->dest_host);
58         strupper(dest_wks);
59
60         if (next_token(NULL, tmp, NULL, sizeof(tmp)))
61         {
62                 info_level = (uint32)strtol(tmp, (char**)NULL, 10);
63         }
64
65         DEBUG(4,("cmd_wks_query_info: server:%s info level: %d\n",
66                                 dest_wks, info_level));
67
68         DEBUG(5, ("cmd_wks_query_info: smb_cli->fd:%d\n", smb_cli->fd));
69
70         /* open LSARPC session. */
71         res = res ? cli_nt_session_open(smb_cli, PIPE_WKSSVC, &nt_pipe_fnum) : False;
72
73         /* send info level: receive requested info.  hopefully. */
74         res = res ? do_wks_query_info(smb_cli, nt_pipe_fnum,
75                                 dest_wks, info_level, &ctr) : False;
76
77         /* close the session */
78         cli_nt_session_close(smb_cli, nt_pipe_fnum);
79
80         if (res)
81         {
82                 DEBUG(5,("cmd_wks_query_info: query succeeded\n"));
83
84 #if 0
85                 display_wks_info_100(out_hnd, ACTION_HEADER   , &ctr);
86                 display_wks_info_100(out_hnd, ACTION_ENUMERATE, &ctr);
87                 display_wks_info_100(out_hnd, ACTION_FOOTER   , &ctr);
88 #endif
89
90         }
91         else
92         {
93                 DEBUG(5,("cmd_wks_query_info: query failed\n"));
94         }
95 }
96