Fix the build.
[kai/samba.git] / source4 / torture / rpc / join.c
1 #include "includes.h"
2 #include "libnet/libnet.h"
3 #include "libcli/libcli.h"
4
5 #include "auth/credentials/credentials.h"
6 #include "torture/rpc/rpc.h"
7
8 #include "libcli/resolve/resolve.h"
9 #include "param/param.h"
10
11 #define TORTURE_NETBIOS_NAME "smbtorturejoin"
12
13
14 bool torture_rpc_join(struct torture_context *torture)
15 {
16         NTSTATUS status;
17         struct test_join *tj;
18         struct cli_credentials *machine_account;
19         struct smbcli_state *cli;
20         const char *host = torture_setting_string(torture, "host", NULL);
21         struct smbcli_options options;
22         struct smbcli_session_options session_options;
23
24         /* Join domain as a member server. */
25         tj = torture_join_domain(torture,
26                                  TORTURE_NETBIOS_NAME,
27                                  ACB_WSTRUST,
28                                  &machine_account);
29
30         if (!tj) {
31                 DEBUG(0, ("%s failed to join domain as workstation\n",
32                           TORTURE_NETBIOS_NAME));
33                 return false;
34         }
35
36         lp_smbcli_options(torture->lp_ctx, &options);
37         lp_smbcli_session_options(torture->lp_ctx, &session_options);
38
39         status = smbcli_full_connection(tj, &cli, host,
40                                         lp_smb_ports(torture->lp_ctx),
41                                         "IPC$", NULL,
42                                         lp_socket_options(torture->lp_ctx),
43                                         machine_account,
44                                         lp_resolve_context(torture->lp_ctx),
45                                         torture->ev, &options, &session_options,
46                                         lp_iconv_convenience(torture->lp_ctx));
47         if (!NT_STATUS_IS_OK(status)) {
48                 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
49                           TORTURE_NETBIOS_NAME));
50                 return false;   
51         }
52         smbcli_tdis(cli);
53         
54         /* Leave domain. */                          
55         torture_leave_domain(torture, tj);
56         
57         /* Join domain as a domain controller. */
58         tj = torture_join_domain(torture, TORTURE_NETBIOS_NAME,
59                                  ACB_SVRTRUST,
60                                  &machine_account);
61         if (!tj) {
62                 DEBUG(0, ("%s failed to join domain as domain controller\n",
63                           TORTURE_NETBIOS_NAME));
64                 return false;
65         }
66
67         status = smbcli_full_connection(tj, &cli, host,
68                                         lp_smb_ports(torture->lp_ctx),
69                                         "IPC$", NULL,
70                                         lp_socket_options(torture->lp_ctx),
71                                         machine_account,
72                                         lp_resolve_context(torture->lp_ctx),
73                                         torture->ev, &options, &session_options,
74                                         lp_iconv_convenience(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;   
79         }
80
81         smbcli_tdis(cli);
82
83         /* Leave domain. */
84         torture_leave_domain(torture, tj);
85
86         return true;
87 }
88