r12608: Remove some unused #include lines.
[kamenim/samba.git] / source4 / torture / libnet / libnet_rpc.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Test suite for libnet calls.
4
5    Copyright (C) Rafal Szczesniak 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 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 #include "lib/cmdline/popt_common.h"
24 #include "libnet/libnet.h"
25
26
27 BOOL test_lsa_connect(struct libnet_context *ctx)
28 {
29         NTSTATUS status;
30         struct libnet_RpcConnect connect;
31         connect.level                     = LIBNET_RPC_CONNECT_PDC;
32         connect.in.domain_name            = lp_workgroup();
33         connect.in.dcerpc_iface                   = &dcerpc_table_lsarpc;
34
35         status = libnet_RpcConnect(ctx, ctx, &connect);
36
37         if (!NT_STATUS_IS_OK(status)) {
38                 printf("Couldn't connect to rpc service %s on %s: %s\n",
39                        connect.in.dcerpc_iface->name, connect.in.domain_name,
40                        nt_errstr(status));
41
42                 return False;
43         }
44
45         return True;
46 }
47
48
49 BOOL test_samr_connect(struct libnet_context *ctx)
50 {
51         NTSTATUS status;
52         struct libnet_RpcConnect connect;
53         connect.level                     = LIBNET_RPC_CONNECT_PDC;
54         connect.in.domain_name            = lp_workgroup();
55         connect.in.dcerpc_iface           = &dcerpc_table_samr;
56
57         status = libnet_RpcConnect(ctx, ctx, &connect);
58
59         if (!NT_STATUS_IS_OK(status)) {
60                 printf("Couldn't connect to rpc service %s on %s: %s\n",
61                        connect.in.dcerpc_iface->name, connect.in.domain_name,
62                        nt_errstr(status));
63
64                 return False;
65         }
66
67         return True;
68 }
69
70
71 BOOL torture_rpc_connect(void)
72 {
73         struct libnet_context *ctx;
74         
75         ctx = libnet_context_init(NULL);
76         ctx->cred = cmdline_credentials;
77
78         if (!test_lsa_connect(ctx)) {
79                 printf("failed to connect lsarpc interface\n");
80                 return False;
81         }
82
83         if (!test_samr_connect(ctx)) {
84                 printf("failed to connect samr interface\n");
85                 return False;
86         }
87
88         return True;
89 }