r4820: add beginnings of 'net rpc rights' for managing privilege assignments
[amitay/samba.git] / source3 / utils / net_rpc_rights.c
1 /* 
2    Samba Unix/Linux SMB client library 
3    Distributed SMB/CIFS Server Management Utility 
4    Copyright (C) Gerald (Jerry) Carter          2004
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19  
20 #include "includes.h"
21 #include "utils/net.h"
22
23 /********************************************************************
24 ********************************************************************/
25
26 static NTSTATUS rpc_rights_list_internal( const DOM_SID *domain_sid, const char *domain_name, 
27                             struct cli_state *cli, TALLOC_CTX *mem_ctx, 
28                             int argc, const char **argv )
29 {
30         return NT_STATUS_OK;
31 }
32
33 /********************************************************************
34 ********************************************************************/
35
36 static NTSTATUS rpc_rights_grant_internal( const DOM_SID *domain_sid, const char *domain_name, 
37                             struct cli_state *cli, TALLOC_CTX *mem_ctx, 
38                             int argc, const char **argv )
39 {
40         return NT_STATUS_OK;
41 }
42
43 /********************************************************************
44 ********************************************************************/
45
46 static NTSTATUS rpc_rights_revoke_internal( const DOM_SID *domain_sid, const char *domain_name, 
47                               struct cli_state *cli, TALLOC_CTX *mem_ctx, 
48                               int argc, const char **argv )
49 {
50         return NT_STATUS_OK;
51 }
52
53 /********************************************************************
54 ********************************************************************/
55
56 static int rpc_rights_list( int argc, const char **argv )
57 {
58         return run_rpc_command( NULL, PI_LSARPC, 0, 
59                 rpc_rights_list_internal, argc, argv );
60 }
61
62 /********************************************************************
63 ********************************************************************/
64
65 static int rpc_rights_grant( int argc, const char **argv )
66 {
67         return run_rpc_command( NULL, PI_LSARPC, 0, 
68                 rpc_rights_grant_internal, argc, argv );
69 }
70
71 /********************************************************************
72 ********************************************************************/
73
74 static int rpc_rights_revoke( int argc, const char **argv )
75 {
76         return run_rpc_command( NULL, PI_LSARPC, 0, 
77                 rpc_rights_revoke_internal, argc, argv );
78 }
79
80 /********************************************************************
81 ********************************************************************/
82
83 static int net_help_rights( int argc, const char **argv )
84 {
85         d_printf("net rpc rights list       View available privileges\n");
86         d_printf("net rpc rights grant      View available privileges\n");
87         d_printf("net rpc rights revoke     View available privileges\n");
88         
89         d_printf("Both 'grant' and 'revoke' require a SID and a commaa separated\n");
90         d_printf("list of privilege names.  For example\n");
91         d_printf("  net rpc grant S-1-5-32-550 SePrintOperatorsPrivilege\n");
92         d_printf("would grant the printer admin right to the 'BUILTIN\\Print Operators' group\n");
93         
94         
95         return -1;
96 }
97
98 /********************************************************************
99 ********************************************************************/
100
101 int net_rpc_rights(int argc, const char **argv) 
102 {
103         struct functable func[] = {
104                 {"list", rpc_rights_list},
105                 {"grant", rpc_rights_grant},
106                 {"revoke", rpc_rights_revoke},
107                 {NULL, NULL}
108         };
109         
110         if ( argc )
111                 return net_run_function( argc, argv, func, net_help_rights );
112                 
113         return net_help_rights( argc, argv );
114 }
115
116