s4: allow python code to dump NTACL object as well
[Samba/ekacnet.git] / source4 / torture / rpc / join.c
blob1d08c60915501920ebf4fcf79e7adbbd866302ea
1 #include "includes.h"
2 #include "libcli/libcli.h"
4 #include "torture/rpc/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 lp_smbcli_options(torture->lp_ctx, &options);
35 lp_smbcli_session_options(torture->lp_ctx, &session_options);
37 status = smbcli_full_connection(tj, &cli, host,
38 lp_smb_ports(torture->lp_ctx),
39 "IPC$", NULL,
40 lp_socket_options(torture->lp_ctx),
41 machine_account,
42 lp_resolve_context(torture->lp_ctx),
43 torture->ev, &options, &session_options,
44 lp_iconv_convenience(torture->lp_ctx),
45 lp_gensec_settings(torture, torture->lp_ctx));
46 if (!NT_STATUS_IS_OK(status)) {
47 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
48 TORTURE_NETBIOS_NAME));
49 return false;
51 smbcli_tdis(cli);
53 /* Leave domain. */
54 torture_leave_domain(torture, tj);
56 /* Join domain as a domain controller. */
57 tj = torture_join_domain(torture, TORTURE_NETBIOS_NAME,
58 ACB_SVRTRUST,
59 &machine_account);
60 if (!tj) {
61 DEBUG(0, ("%s failed to join domain as domain controller\n",
62 TORTURE_NETBIOS_NAME));
63 return false;
66 status = smbcli_full_connection(tj, &cli, host,
67 lp_smb_ports(torture->lp_ctx),
68 "IPC$", NULL,
69 lp_socket_options(torture->lp_ctx),
70 machine_account,
71 lp_resolve_context(torture->lp_ctx),
72 torture->ev, &options, &session_options,
73 lp_iconv_convenience(torture->lp_ctx),
74 lp_gensec_settings(torture, torture->lp_ctx));
75 if (!NT_STATUS_IS_OK(status)) {
76 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
77 TORTURE_NETBIOS_NAME));
78 return false;
81 smbcli_tdis(cli);
83 /* Leave domain. */
84 torture_leave_domain(torture, tj);
86 return true;