r5671: Bunch of fixes related to arrays and pointers to arrays.
[Samba/gebeck_regimport.git] / source4 / torture / rpc / remact.c
blob9db1e4f164d29618fc39a099c505c59fba658495
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for remoteactivation operations
5 Copyright (C) Jelmer Vernooij 2004
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_remact.h"
24 #include "librpc/gen_ndr/ndr_epmapper.h"
26 #define CLSID_TEST "00000316-0000-0000-C000-000000000046"
27 #define CLSID_SIMPLE "5e9ddec7-5767-11cf-beab-00aa006c3606"
28 #define CLSID_COFFEEMACHINE "DB7C21F8-FE33-4C11-AEA5-CEB56F076FBB"
30 static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
32 struct RemoteActivation r;
33 NTSTATUS status;
34 struct GUID iids[2];
35 uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
37 ZERO_STRUCT(r.in);
38 r.in.this.version.MajorVersion = 5;
39 r.in.this.version.MinorVersion = 1;
40 r.in.this.cid = GUID_random();
41 GUID_from_string(CLSID_SIMPLE, &r.in.Clsid);
42 r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
43 r.in.num_protseqs = 3;
44 r.in.protseq = protseq;
45 r.in.Interfaces = 2;
46 GUID_from_string(DCERPC_IUNKNOWN_UUID, &iids[0]);
47 GUID_from_string(DCERPC_ISTREAM_UUID, &iids[1]);
48 r.in.pIIDs = iids;
50 status = dcerpc_RemoteActivation(p, mem_ctx, &r);
51 if(NT_STATUS_IS_ERR(status)) {
52 printf("RemoteActivation: %s\n", nt_errstr(status));
53 return 0;
56 if(!W_ERROR_IS_OK(r.out.result)) {
57 printf("RemoteActivation: %s\n", win_errstr(r.out.result));
58 return 0;
61 if(!W_ERROR_IS_OK(r.out.hr)) {
62 printf("RemoteActivation: %s\n", win_errstr(r.out.hr));
63 return 0;
66 if(!W_ERROR_IS_OK(r.out.results[0])) {
67 printf("RemoteActivation: %s\n", win_errstr(r.out.results[0]));
68 return 0;
71 GUID_from_string(DCERPC_ICLASSFACTORY_UUID, &iids[0]);
72 r.in.Interfaces = 1;
73 r.in.Mode = MODE_GET_CLASS_OBJECT;
75 status = dcerpc_RemoteActivation(p, mem_ctx, &r);
76 if(NT_STATUS_IS_ERR(status)) {
77 printf("RemoteActivation(GetClassObject): %s\n", nt_errstr(status));
78 return 0;
81 if(!W_ERROR_IS_OK(r.out.result)) {
82 printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.result));
83 return 0;
86 if(!W_ERROR_IS_OK(r.out.hr)) {
87 printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.hr));
88 return 0;
91 if(!W_ERROR_IS_OK(r.out.results[0])) {
92 printf("RemoteActivation: %s\n", win_errstr(r.out.results[0]));
93 return 0;
96 return 1;
99 BOOL torture_rpc_remact(void)
101 NTSTATUS status;
102 struct dcerpc_pipe *p;
103 TALLOC_CTX *mem_ctx;
104 BOOL ret = True;
106 mem_ctx = talloc_init("torture_rpc_remact");
108 status = torture_rpc_connection(&p,
109 DCERPC_IREMOTEACTIVATION_NAME,
110 DCERPC_IREMOTEACTIVATION_UUID,
111 DCERPC_IREMOTEACTIVATION_VERSION);
113 if (!NT_STATUS_IS_OK(status)) {
114 return False;
117 if(!test_RemoteActivation(p, mem_ctx))
118 ret = False;
120 talloc_free(mem_ctx);
122 torture_rpc_close(p);
124 return ret;