libcli/cldap: make use of samba_tevent_context_init()
[Samba/gebeck_regimport.git] / source4 / torture / rpc / join.c
blob6e0afcac28187ed2436288867f68a2729388e580
1 #include "includes.h"
2 #include "libcli/libcli.h"
4 #include "torture/rpc/torture_rpc.h"
6 #include "libcli/resolve/resolve.h"
7 #include "param/param.h"
9 #define TORTURE_NETBIOS_NAME "smbtorturejoin"
12 bool torture_rpc_join(struct torture_context *torture)
14 NTSTATUS status;
15 struct test_join *tj;
16 struct cli_credentials *machine_account;
17 struct smbcli_state *cli;
18 const char *host = torture_setting_string(torture, "host", NULL);
19 struct smbcli_options options;
20 struct smbcli_session_options session_options;
22 /* Join domain as a member server. */
23 tj = torture_join_domain(torture,
24 TORTURE_NETBIOS_NAME,
25 ACB_WSTRUST,
26 &machine_account);
28 if (!tj) {
29 DEBUG(0, ("%s failed to join domain as workstation\n",
30 TORTURE_NETBIOS_NAME));
31 return false;
34 lpcfg_smbcli_options(torture->lp_ctx, &options);
35 lpcfg_smbcli_session_options(torture->lp_ctx, &session_options);
37 status = smbcli_full_connection(tj, &cli, host,
38 lpcfg_smb_ports(torture->lp_ctx),
39 "IPC$", NULL,
40 lpcfg_socket_options(torture->lp_ctx),
41 machine_account,
42 lpcfg_resolve_context(torture->lp_ctx),
43 torture->ev, &options, &session_options,
44 lpcfg_gensec_settings(torture, torture->lp_ctx));
45 if (!NT_STATUS_IS_OK(status)) {
46 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
47 TORTURE_NETBIOS_NAME));
48 return false;
50 smbcli_tdis(cli);
52 /* Leave domain. */
53 torture_leave_domain(torture, tj);
55 /* Join domain as a domain controller. */
56 tj = torture_join_domain(torture, TORTURE_NETBIOS_NAME,
57 ACB_SVRTRUST,
58 &machine_account);
59 if (!tj) {
60 DEBUG(0, ("%s failed to join domain as domain controller\n",
61 TORTURE_NETBIOS_NAME));
62 return false;
65 status = smbcli_full_connection(tj, &cli, host,
66 lpcfg_smb_ports(torture->lp_ctx),
67 "IPC$", NULL,
68 lpcfg_socket_options(torture->lp_ctx),
69 machine_account,
70 lpcfg_resolve_context(torture->lp_ctx),
71 torture->ev, &options, &session_options,
72 lpcfg_gensec_settings(torture, torture->lp_ctx));
73 if (!NT_STATUS_IS_OK(status)) {
74 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
75 TORTURE_NETBIOS_NAME));
76 return false;
79 smbcli_tdis(cli);
81 /* Leave domain. */
82 torture_leave_domain(torture, tj);
84 return true;