we only want the per-call stub data
[bbaumbach/samba-autobuild/.git] / source4 / torture / rpc / lsa.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for lsa rpc operations
4    Copyright (C) Tim Potter 2003
5    Copyright (C) Andrew Tridgell 2003
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 2 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, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23
24 /* Helper function for RPC-OPEN test */
25 static DATA_BLOB blob_lsa_open_policy_req(TALLOC_CTX *mem_ctx, BOOL sec_qos, 
26                                           uint32 des_access)
27 {
28         prs_struct qbuf;
29         LSA_Q_OPEN_POL q;
30         LSA_SEC_QOS qos;
31
32         ZERO_STRUCT(q);
33
34         /* Initialise parse structures */
35
36         prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
37
38         /* Initialise input parameters */
39         if (sec_qos) {
40                 init_lsa_sec_qos(&qos, 2, 1, 0);
41                 init_q_open_pol(&q, '\\', 0, des_access, &qos);
42         } else {
43                 init_q_open_pol(&q, '\\', 0, des_access, NULL);
44         }
45
46         if (lsa_io_q_open_pol("", &q, &qbuf, 0))
47                 return data_blob_talloc(
48                         mem_ctx, prs_data_p(&qbuf), prs_offset(&qbuf));
49
50         return data_blob(NULL, 0);
51 }
52
53 BOOL torture_rpc_lsa(int dummy)
54 {
55         NTSTATUS status;
56         struct dcerpc_pipe *p;
57         DATA_BLOB request, response;
58         TALLOC_CTX *mem_ctx;
59
60         mem_ctx = talloc_init("torture_rpc_lsa");
61
62         status = torture_rpc_connection(&p, "lsarpc");
63         if (!NT_STATUS_IS_OK(status)) {
64                 return False;
65         }
66         
67         request = blob_lsa_open_policy_req(mem_ctx, True, 
68                                            SEC_RIGHTS_MAXIMUM_ALLOWED);
69
70         status = cli_dcerpc_request(p, LSA_OPENPOLICY, mem_ctx, &request, &response);
71         if (!NT_STATUS_IS_OK(status)) {
72                 d_printf("Failed to LSA_OPENPOLICY - %s\n", nt_errstr(status));
73         }
74
75         torture_rpc_close(p);
76
77         return NT_STATUS_IS_OK(status);
78 }