r26252: Specify loadparm_context explicitly when creating sessions.
[jelmer/samba4-debian.git] / source / 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 #define TORTURE_NETBIOS_NAME "smbtorturejoin"
9
10
11 bool torture_rpc_join(struct torture_context *torture)
12 {
13         NTSTATUS status;
14         struct test_join *tj;
15         struct cli_credentials *machine_account;
16         struct smbcli_state *cli;
17         const char *host = torture_setting_string(torture, "host", NULL);
18
19         /* Join domain as a member server. */
20         tj = torture_join_domain(torture,
21                                  TORTURE_NETBIOS_NAME,
22                                  ACB_WSTRUST,
23                                  &machine_account);
24
25         if (!tj) {
26                 DEBUG(0, ("%s failed to join domain as workstation\n",
27                           TORTURE_NETBIOS_NAME));
28                 return false;
29         }
30
31         status = smbcli_full_connection(tj, &cli, host,
32                                         "IPC$", NULL,
33                                         machine_account,
34                                         NULL);
35         if (!NT_STATUS_IS_OK(status)) {
36                 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
37                           TORTURE_NETBIOS_NAME));
38                 return false;   
39         }
40         smbcli_tdis(cli);
41         
42         /* Leave domain. */                          
43         torture_leave_domain(tj);
44         
45         /* Join domain as a domain controller. */
46         tj = torture_join_domain(torture, TORTURE_NETBIOS_NAME,
47                                  ACB_SVRTRUST,
48                                  &machine_account);
49         if (!tj) {
50                 DEBUG(0, ("%s failed to join domain as domain controller\n",
51                           TORTURE_NETBIOS_NAME));
52                 return false;
53         }
54
55         status = smbcli_full_connection(tj, &cli, host,
56                                         "IPC$", NULL,
57                                         machine_account,
58                                         NULL);
59         if (!NT_STATUS_IS_OK(status)) {
60                 DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
61                           TORTURE_NETBIOS_NAME));
62                 return false;   
63         }
64
65         smbcli_tdis(cli);
66
67         /* Leave domain. */
68         torture_leave_domain(tj);
69
70         return true;
71 }
72