1 | #include "includes.h"
|
---|
2 | #include "libcli/libcli.h"
|
---|
3 |
|
---|
4 | #include "torture/rpc/torture_rpc.h"
|
---|
5 |
|
---|
6 | #include "libcli/resolve/resolve.h"
|
---|
7 | #include "param/param.h"
|
---|
8 |
|
---|
9 | #define TORTURE_NETBIOS_NAME "smbtorturejoin"
|
---|
10 |
|
---|
11 |
|
---|
12 | bool torture_rpc_join(struct torture_context *torture)
|
---|
13 | {
|
---|
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;
|
---|
21 |
|
---|
22 | /* Join domain as a member server. */
|
---|
23 | tj = torture_join_domain(torture,
|
---|
24 | TORTURE_NETBIOS_NAME,
|
---|
25 | ACB_WSTRUST,
|
---|
26 | &machine_account);
|
---|
27 |
|
---|
28 | if (!tj) {
|
---|
29 | DEBUG(0, ("%s failed to join domain as workstation\n",
|
---|
30 | TORTURE_NETBIOS_NAME));
|
---|
31 | return false;
|
---|
32 | }
|
---|
33 |
|
---|
34 | lpcfg_smbcli_options(torture->lp_ctx, &options);
|
---|
35 | lpcfg_smbcli_session_options(torture->lp_ctx, &session_options);
|
---|
36 |
|
---|
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;
|
---|
49 | }
|
---|
50 | smbcli_tdis(cli);
|
---|
51 |
|
---|
52 | /* Leave domain. */
|
---|
53 | torture_leave_domain(torture, tj);
|
---|
54 |
|
---|
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;
|
---|
63 | }
|
---|
64 |
|
---|
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;
|
---|
77 | }
|
---|
78 |
|
---|
79 | smbcli_tdis(cli);
|
---|
80 |
|
---|
81 | /* Leave domain. */
|
---|
82 | torture_leave_domain(torture, tj);
|
---|
83 |
|
---|
84 | return true;
|
---|
85 | }
|
---|
86 |
|
---|