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