r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[samba.git] / source3 / rpcclient / cmd_test.c
1 /* 
2    Unix SMB/CIFS implementation.
3    RPC pipe client
4
5    Copyright (C) Volker Lendecke 2005
6
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.
11    
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.
16    
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/>.
19 */
20
21 #include "includes.h"
22 #include "rpcclient.h"
23
24 static NTSTATUS cmd_testme(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
25                            int argc, const char **argv)
26 {
27         struct rpc_pipe_client *lsa_pipe = NULL, *samr_pipe = NULL;
28         NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
29         POLICY_HND pol;
30
31         d_printf("testme\n");
32
33         lsa_pipe = cli_rpc_pipe_open_noauth(cli->cli, PI_LSARPC, &status);
34         if (lsa_pipe == NULL) goto done;
35
36         samr_pipe = cli_rpc_pipe_open_noauth(cli->cli, PI_SAMR, &status);
37         if (samr_pipe == NULL) goto done;
38
39         status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False,
40                                         SEC_RIGHTS_QUERY_VALUE, &pol);
41
42         if (!NT_STATUS_IS_OK(status))
43                 goto done;
44
45         status = rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol);
46
47         if (!NT_STATUS_IS_OK(status))
48                 goto done;
49
50  done:
51         if (lsa_pipe != NULL) cli_rpc_pipe_close(lsa_pipe);
52         if (samr_pipe != NULL) cli_rpc_pipe_close(samr_pipe);
53
54         return status;
55 }
56
57 /* List of commands exported by this module */
58
59 struct cmd_set test_commands[] = {
60
61         { "TESTING" },
62
63         { "testme", RPC_RTYPE_NTSTATUS, cmd_testme, NULL,
64           -1, NULL, "Sample test", "testme" },
65
66         { NULL }
67 };