summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-11-03 21:44:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:24 -0500
commit9a65c54c72cb5cbbe3d57df32193568850266b3b (patch)
tree40c727a6f0ca0807b4ba4b889f100bb2006665a9
parent6d3c74a67b935f348777feb3fac7653a9c4277a8 (diff)
downloadsamba-9a65c54c72cb5cbbe3d57df32193568850266b3b.tar.gz
samba-9a65c54c72cb5cbbe3d57df32193568850266b3b.tar.bz2
samba-9a65c54c72cb5cbbe3d57df32193568850266b3b.zip
r3514: Allow specification of username, password and domain and try to set up connection.
(This used to be commit 8076db7a1f9e11c725e481a0bda4dbc354c9612f)
-rw-r--r--source4/lib/dcom/common/dcom.h4
-rw-r--r--source4/lib/dcom/common/main.c120
-rw-r--r--source4/librpc/idl/dcom.idl6
-rw-r--r--source4/torture/dcom/simple.c2
4 files changed, 101 insertions, 31 deletions
diff --git a/source4/lib/dcom/common/dcom.h b/source4/lib/dcom/common/dcom.h
index 871bead376..091200d4c1 100644
--- a/source4/lib/dcom/common/dcom.h
+++ b/source4/lib/dcom/common/dcom.h
@@ -21,6 +21,10 @@
#ifndef _DCOM_H /* _DCOM_H */
#define _DCOM_H
+struct IUnknown_AddRef;
+struct IUnknown_Release;
+struct IUnknown_QueryInterface;
+
struct dcom_interface
{
struct dcerpc_pipe *pipe;
diff --git a/source4/lib/dcom/common/main.c b/source4/lib/dcom/common/main.c
index f567b639e5..3c95caebe0 100644
--- a/source4/lib/dcom/common/main.c
+++ b/source4/lib/dcom/common/main.c
@@ -22,54 +22,121 @@
#include "librpc/gen_ndr/ndr_epmapper.h"
#include "librpc/gen_ndr/ndr_remact.h"
-static WERROR dcom_binding_from_oxid(TALLOC_CTX *mem_ctx, HYPER_T oxid, struct dcerpc_binding *bd)
-{
- /* FIXME */
- return WERR_NOT_SUPPORTED;
-}
+#define DCOM_NEGOTIATED_PROTOCOLS { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NCALRPC }
-static WERROR dcom_tower_from_oxid(TALLOC_CTX *mem_ctx, HYPER_T oxid, struct epm_tower *bd)
+static NTSTATUS dcom_connect(struct dcerpc_pipe **p, const char *server, const char *domain, const char *user, const char *pass)
{
- /* FIXME */
- return WERR_NOT_SUPPORTED;
+ struct dcerpc_binding bd;
+ enum dcerpc_transport_t available_transports[] = { NCACN_IP_TCP, NCACN_NP };
+ int i;
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx = talloc_init("dcom_connect");
+
+ /* Allow server name to contain a binding string */
+ if (NT_STATUS_IS_OK(dcerpc_parse_binding(mem_ctx, server, &bd))) {
+ status = dcerpc_pipe_connect_b(p, &bd, DCERPC_IREMOTEACTIVATION_UUID, DCERPC_IREMOTEACTIVATION_VERSION, domain, user, pass);
+ talloc_destroy(mem_ctx);
+ return status;
+ }
+ talloc_destroy(mem_ctx);
+
+ ZERO_STRUCT(bd);
+ bd.host = server;
+
+ if (server == NULL) {
+ bd.transport = NCALRPC;
+ return dcerpc_pipe_connect_b(p, &bd, DCERPC_IREMOTEACTIVATION_UUID, DCERPC_IREMOTEACTIVATION_VERSION, domain, user, pass);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(available_transports); i++)
+ {
+ bd.transport = available_transports[i];
+
+ status = dcerpc_pipe_connect_b(p, &bd, DCERPC_IREMOTEACTIVATION_UUID, DCERPC_IREMOTEACTIVATION_VERSION, domain, user, pass);
+
+ if (NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ }
+
+ return status;
}
-static WERROR dcom_create_instance (struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct GUID clsid)
+static WERROR dcom_connect_oxid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe **p, HYPER_T oxid)
{
+ /* FIXME */
return WERR_NOT_SUPPORTED;
}
-static uint32 IUnknown_AddRef(void)
+NTSTATUS dcerpc_IUnknown_AddRef(struct dcerpc_pipe *p, struct GUID *o, TALLOC_CTX *mem_ctx, struct IUnknown_AddRef *r)
{
/* FIXME: Tell local server we're adding a reference to this interface on this object. Local server can then call RemAddRef() if necessary */
- return 0;
+ return NT_STATUS_NOT_SUPPORTED;
}
-static uint32 IUnknown_Release(void)
+NTSTATUS dcerpc_IUnknown_Release(struct dcerpc_pipe *p, struct GUID *o, TALLOC_CTX *mem_ctx, struct IUnknown_Release *r)
{
/* FIXME: Tell local server we're releasing a reference to this interface on this object. Local server can then call RemRelease() if necessary */
- return 0;
+ return NT_STATUS_NOT_SUPPORTED;
}
-static WERROR IUnknown_QueryInterface(struct GUID *riid, void **data)
+NTSTATUS dcerpc_IUnknown_QueryInterface(struct dcerpc_pipe *p, struct GUID *o, TALLOC_CTX *mem_ctx, struct IUnknown_QueryInterface *r)
{
/* FIXME: Ask local server for interface pointer. Local server can then
* call RemQueryInterface if necessary */
- return WERR_NOT_SUPPORTED;
+ return NT_STATUS_NOT_SUPPORTED;
}
-WERROR dcom_create_object(TALLOC_CTX *mem_ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct dcom_interface **ip)
+WERROR dcom_create_object(TALLOC_CTX *mem_ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct dcom_interface **ip, const char *domain, const char *user, const char *pass)
{
- return WERR_NOT_SUPPORTED;
+ struct RemoteActivation r;
+ struct dcerpc_pipe *p;
+ NTSTATUS status;
+ uint16 protseq[] = DCOM_NEGOTIATED_PROTOCOLS;
+
+ status = dcom_connect(&p, server, domain, user, pass);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(1, ("Unable to connect to %s - %s\n", server, nt_errstr(status)));
+ return ntstatus_to_werror(status);
+ }
+
+ ZERO_STRUCT(r.in);
+ r.in.this.version.MajorVersion = 5;
+ r.in.this.version.MinorVersion = 1;
+ uuid_generate_random(&r.in.this.cid);
+ r.in.Clsid = *clsid;
+ r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
+ r.in.num_protseqs = ARRAY_SIZE(protseq);
+ r.in.protseq = protseq;
+ r.in.Interfaces = num_ifaces;
+ r.in.pIIDs = iid;
+
+ status = dcerpc_RemoteActivation(p, mem_ctx, &r);
+ if(NT_STATUS_IS_ERR(status)) {
+ DEBUG(1, ("Error while running RemoteActivation %s\n", nt_errstr(status)));
+ return ntstatus_to_werror(status);
+ }
+
+ if(!W_ERROR_IS_OK(r.out.result)) { return r.out.result; }
+ if(!W_ERROR_IS_OK(r.out.hr)) { return r.out.hr; }
+ if(!W_ERROR_IS_OK(r.out.results[0])) { return r.out.results[0]; }
+
+ /* FIXME: Fill ip */
+ return WERR_OK;
}
-WERROR dcom_get_class_object(TALLOC_CTX *mem_ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct dcom_interface **ip)
+WERROR dcom_get_class_object(TALLOC_CTX *mem_ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct dcom_interface **ip, const char *domain, const char *user, const char *pass)
{
struct RemoteActivation r;
- struct dcerpc_pipe *p = NULL; /* FIXME */
+ struct dcerpc_pipe *p;
NTSTATUS status;
- struct GUID iids[2];
- uint16 protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
+ uint16 protseq[] = DCOM_NEGOTIATED_PROTOCOLS;
+
+ status = dcom_connect(&p, server, domain, user, pass);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(1, ("Unable to connect to %s - %s\n", server, nt_errstr(status)));
+ return ntstatus_to_werror(status);
+ }
ZERO_STRUCT(r.in);
r.in.this.version.MajorVersion = 5;
@@ -77,16 +144,15 @@ WERROR dcom_get_class_object(TALLOC_CTX *mem_ctx, struct GUID *clsid, const char
uuid_generate_random(&r.in.this.cid);
r.in.Clsid = *clsid;
r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
- r.in.num_protseqs = 3;
+ r.in.num_protseqs = ARRAY_SIZE(protseq);
r.in.protseq = protseq;
r.in.Interfaces = 1;
- GUID_from_string(DCERPC_IUNKNOWN_UUID, &iids[0]);
- r.in.pIIDs = iids;
+ r.in.pIIDs = iid;
r.in.Mode = MODE_GET_CLASS_OBJECT;
status = dcerpc_RemoteActivation(p, mem_ctx, &r);
if(NT_STATUS_IS_ERR(status)) {
- fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status));
+ DEBUG(1, ("Error while running RemoteActivation - %s\n", nt_errstr(status)));
return ntstatus_to_werror(status);
}
@@ -94,6 +160,6 @@ WERROR dcom_get_class_object(TALLOC_CTX *mem_ctx, struct GUID *clsid, const char
if(!W_ERROR_IS_OK(r.out.hr)) { return r.out.hr; }
if(!W_ERROR_IS_OK(r.out.results[0])) { return r.out.results[0]; }
-
- return WERR_NOT_SUPPORTED;
+ /* FIXME: Fill ip */
+ return WERR_OK;
}
diff --git a/source4/librpc/idl/dcom.idl b/source4/librpc/idl/dcom.idl
index d0fae2f0cc..448ed827f9 100644
--- a/source4/librpc/idl/dcom.idl
+++ b/source4/librpc/idl/dcom.idl
@@ -279,16 +279,16 @@ interface IUnknown
/* Function 0x00 */
/* Returns the interface with the specified IID
if implemented by this object */
- [local] WERROR QueryInterface([in] IID *riid,
+ [local] WERROR IUnknown_QueryInterface([in] IID *riid,
[out,iid_is(riid)] MInterfacePointer *data);
/*****************/
/* Function 0x01 */
- [local] uint32 AddRef();
+ [local] uint32 IUnknown_AddRef();
/*****************/
/* Function 0x02 */
- [local] uint32 Release();
+ [local] uint32 IUnknown_Release();
}
diff --git a/source4/torture/dcom/simple.c b/source4/torture/dcom/simple.c
index b52733e1f6..23db926880 100644
--- a/source4/torture/dcom/simple.c
+++ b/source4/torture/dcom/simple.c
@@ -45,7 +45,7 @@ BOOL torture_dcom_simple(void)
GUID_from_string(DCERPC_ISTREAM_UUID, &IID[0]);
GUID_from_string(DCERPC_IUNKNOWN_UUID, &IID[1]);
GUID_from_string(CLSID_SIMPLE, &clsid);
- error = dcom_create_object(mem_ctx, &clsid, "192.168.4.28", 2, IID, &interfaces);
+ error = dcom_create_object(mem_ctx, &clsid, lp_parm_string(-1, "torture", "binding"), 2, IID, &interfaces, lp_parm_string(-1, "torture", "userdomain"), lp_parm_string(-1, "torture", "username"), lp_parm_string(-1, "torture", "password"));
if (!W_ERROR_IS_OK(error)) {
printf("dcom_create_object failed - %s\n", win_errstr(error));