summaryrefslogtreecommitdiff
path: root/source4/lib/wmi/tools
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-14 16:39:57 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-15 17:40:24 +0200
commit2fc75a6c4e930cee03ab53ab758b60fc4f9ff0f7 (patch)
tree3b6d68bb160b07e8a4d4d104ced1c8cb7a329a0b /source4/lib/wmi/tools
parent307f7d7d77abe1e76af074333d9527558a7e7ee1 (diff)
downloadsamba-2fc75a6c4e930cee03ab53ab758b60fc4f9ff0f7.tar.gz
samba-2fc75a6c4e930cee03ab53ab758b60fc4f9ff0f7.tar.bz2
samba-2fc75a6c4e930cee03ab53ab758b60fc4f9ff0f7.zip
Adapt to changes in Samba API's, fix formatting.
Diffstat (limited to 'source4/lib/wmi/tools')
-rw-r--r--source4/lib/wmi/tools/wmic.c27
-rw-r--r--source4/lib/wmi/tools/wmis.c32
2 files changed, 20 insertions, 39 deletions
diff --git a/source4/lib/wmi/tools/wmic.c b/source4/lib/wmi/tools/wmic.c
index 611a2dc36f..3d5d654eb8 100644
--- a/source4/lib/wmi/tools/wmic.c
+++ b/source4/lib/wmi/tools/wmic.c
@@ -1,6 +1,7 @@
/*
WMI Sample client
Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl>
+ Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,16 +28,12 @@
#include "librpc/gen_ndr/ndr_remact_c.h"
#include "librpc/gen_ndr/ndr_epmapper_c.h"
#include "librpc/gen_ndr/com_dcom.h"
-#include "librpc/rpc/dcerpc_table.h"
#include "lib/com/dcom/dcom.h"
#include "lib/com/proto.h"
#include "lib/com/dcom/proto.h"
-struct WBEMCLASS;
-struct WBEMOBJECT;
-
-#include "wmi/wmi.h"
+#include "lib/wmi/wmi.h"
struct program_args {
char *hostname;
@@ -164,23 +161,11 @@ int main(int argc, char **argv)
WERROR result;
NTSTATUS status;
struct IWbemServices *pWS = NULL;
+ struct BSTR queryLanguage, query;
parse_args(argc, argv, &args);
- dcerpc_init();
- dcerpc_table_init();
-
- dcom_proxy_IUnknown_init();
- dcom_proxy_IWbemLevel1Login_init();
- dcom_proxy_IWbemServices_init();
- dcom_proxy_IEnumWbemClassObject_init();
- dcom_proxy_IRemUnknown_init();
- dcom_proxy_IWbemFetchSmartEnum_init();
- dcom_proxy_IWbemWCOSmartEnum_init();
-
- struct com_context *ctx = NULL;
- com_init_ctx(&ctx, NULL);
- dcom_client_init(ctx, cmdline_credentials);
+ wmi_init(&ctx, cmdline_credentials);
if (!args.ns)
args.ns = "root\\cimv2";
@@ -188,7 +173,9 @@ int main(int argc, char **argv)
WERR_CHECK("Login to remote object.");
struct IEnumWbemClassObject *pEnum = NULL;
- result = IWbemServices_ExecQuery(pWS, ctx, "WQL", args.query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_ENSURE_LOCATABLE, NULL, &pEnum);
+ queryLanguage.data = "WQL";
+ query.data = args.query;
+ result = IWbemServices_ExecQuery(pWS, ctx, queryLanguage, query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_ENSURE_LOCATABLE, NULL, &pEnum);
WERR_CHECK("WMI query execute.");
IEnumWbemClassObject_Reset(pEnum, ctx);
diff --git a/source4/lib/wmi/tools/wmis.c b/source4/lib/wmi/tools/wmis.c
index 72ca4ebdfe..2b7abbb7bc 100644
--- a/source4/lib/wmi/tools/wmis.c
+++ b/source4/lib/wmi/tools/wmis.c
@@ -141,10 +141,13 @@ WERROR WBEM_RemoteExecute(struct IWbemServices *pWS, const char *cmdline, uint32
WERROR result;
union CIMVAR v;
TALLOC_CTX *ctx;
+ struct BSTR objectPath, methodName;
ctx = talloc_new(0);
- result = IWbemServices_GetObject(pWS, ctx, "Win32_Process",
+ objectPath.data = "Win32_Process";
+
+ result = IWbemServices_GetObject(pWS, ctx, objectPath,
WBEM_FLAG_RETURN_WBEM_COMPLETE, NULL, &wco, NULL);
WERR_CHECK("GetObject.");
@@ -158,7 +161,8 @@ WERROR WBEM_RemoteExecute(struct IWbemServices *pWS, const char *cmdline, uint32
result = IWbemClassObject_Put(in, ctx, "CommandLine", 0, &v, 0);
WERR_CHECK("IWbemClassObject_Put(CommandLine).");
- result = IWbemServices_ExecMethod(pWS, ctx, "Win32_Process", "Create", 0, NULL, in, &out,
+ methodName.data = "Create";
+ result = IWbemServices_ExecMethod(pWS, ctx, objectPath, methodName, 0, NULL, in, &out,
NULL);
WERR_CHECK("IWbemServices_ExecMethod.");
@@ -181,24 +185,12 @@ int main(int argc, char **argv)
struct IWbemServices *pWS = NULL;
struct IEnumWbemClassObject *pEnum = NULL;
uint32_t cnt;
+ struct BSTR queryLanguage;
+ struct BSTR query;
parse_args(argc, argv, &args);
- dcerpc_init();
- ndr_table_init();
-
- dcom_proxy_IUnknown_init();
- dcom_proxy_IWbemLevel1Login_init();
- dcom_proxy_IWbemServices_init();
- dcom_proxy_IEnumWbemClassObject_init();
- dcom_proxy_IRemUnknown_init();
- dcom_proxy_IWbemFetchSmartEnum_init();
- dcom_proxy_IWbemWCOSmartEnum_init();
- dcom_proxy_IWbemClassObject_init();
-
- com_init_ctx(&ctx, NULL);
- dcom_client_init(ctx, cmdline_credentials);
-
+ wmi_init(&ctx, cmdline_credentials);
result = WBEM_ConnectServer(ctx, args.hostname, "root\\cimv2", 0, 0, 0, 0, 0, 0, &pWS);
WERR_CHECK("WBEM_ConnectServer.");
@@ -208,8 +200,10 @@ int main(int argc, char **argv)
printf("2: ReturnCode: %d\n", cnt);
printf("3: Monitoring directory C:\\wmi_test_dir_tmp. Please create/delete files in that directory to see notifications, after 4 events program quits.\n");
- result = IWbemServices_ExecNotificationQuery(pWS, ctx, "WQL",
- "SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and TargetInstance.GroupComponent= 'Win32_Directory.Name=\"C:\\\\\\\\wmi_test_dir_tmp\"'", WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
+ query.data = "SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and TargetInstance.GroupComponent= 'Win32_Directory.Name=\"C:\\\\\\\\wmi_test_dir_tmp\"'";
+ queryLanguage.data = "WQL";
+ result = IWbemServices_ExecNotificationQuery(pWS, ctx, queryLanguage,
+ query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
WERR_CHECK("WMI query execute.");
for (cnt = 0; cnt < 4; ++cnt) {
struct WbemClassObject *co;