2 Unix SMB/CIFS implementation.
3 Test suite for libnet calls.
5 Copyright (C) Rafal Szczesniak 2005
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.
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.
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.
23 #include "lib/cmdline/popt_common.h"
24 #include "libnet/libnet.h"
25 #include "libcli/security/security.h"
26 #include "librpc/ndr/libndr.h"
27 #include "librpc/gen_ndr/ndr_lsa.h"
28 #include "librpc/gen_ndr/ndr_samr.h"
29 #include "librpc/rpc/dcerpc.h"
30 #include "torture/torture.h"
33 static BOOL test_lsa_connect(struct libnet_context *ctx)
36 struct libnet_RpcConnect connect;
37 connect.level = LIBNET_RPC_CONNECT_BINDING;
38 connect.in.binding = lp_parm_string(-1, "torture", "binding");
39 connect.in.dcerpc_iface = &dcerpc_table_lsarpc;
41 status = libnet_RpcConnect(ctx, ctx, &connect);
43 if (!NT_STATUS_IS_OK(status)) {
44 printf("Couldn't connect to rpc service %s on %s: %s\n",
45 connect.in.dcerpc_iface->name, connect.in.binding,
55 static BOOL test_lsa_dcinfo_connect(struct libnet_context *ctx)
58 struct libnet_RpcConnect connect;
59 connect.level = LIBNET_RPC_CONNECT_DC_INFO;
60 connect.in.binding = lp_parm_string(-1, "torture", "binding");
61 connect.in.dcerpc_iface = &dcerpc_table_lsarpc;
63 status = libnet_RpcConnect(ctx, ctx, &connect);
65 if (!NT_STATUS_IS_OK(status)) {
66 printf("Couldn't connect to rpc service %s on %s: %s\n",
67 connect.in.dcerpc_iface->name, connect.in.binding,
73 printf("Domain Controller Info:\n");
74 printf("\tDomain Name:\t %s\n", connect.out.domain_name);
75 printf("\tDomain SID:\t %s\n", dom_sid_string(ctx, connect.out.domain_sid));
76 printf("\tRealm:\t\t %s\n", connect.out.realm);
77 printf("\tGUID:\t\t %s\n", GUID_string(ctx, connect.out.guid));
83 static BOOL test_samr_connect(struct libnet_context *ctx)
86 struct libnet_RpcConnect connect;
87 connect.level = LIBNET_RPC_CONNECT_BINDING;
88 connect.in.binding = lp_parm_string(-1, "torture", "binding");
89 connect.in.dcerpc_iface = &dcerpc_table_samr;
91 status = libnet_RpcConnect(ctx, ctx, &connect);
93 if (!NT_STATUS_IS_OK(status)) {
94 printf("Couldn't connect to rpc service %s on %s: %s\n",
95 connect.in.dcerpc_iface->name, connect.in.binding,
104 BOOL torture_rpc_connect(struct torture_context *torture)
106 struct libnet_context *ctx;
108 ctx = libnet_context_init(NULL);
109 ctx->cred = cmdline_credentials;
111 printf("Testing connection to lsarpc interface\n");
112 if (!test_lsa_connect(ctx)) {
113 printf("failed to connect lsarpc interface\n");
117 printf("Testing connection with domain info to lsarpc interface\n");
118 if (!test_lsa_dcinfo_connect(ctx)) {
119 printf("failed to connect lsarpc interface\n");
123 printf("Testing connection to SAMR service\n");
124 if (!test_samr_connect(ctx)) {
125 printf("failed to connect samr interface\n");