Commit 1c655f8e authored by Charlène Auger's avatar Charlène Auger
Browse files

Add dynamic wmi_flag_mode retrieved by .ini file

parent 3f8930af
......@@ -775,5 +775,13 @@ BOOL COCSInventoryApp::parseCommandLine()
// /NOTIFY
if (isRequired( m_lpCmdLine, _T( "notify")))
m_pConfig->setNotify( TRUE);
// /WMI_FLAG_MODE[=READ/COMPLETE]^M
if (isRequired(m_lpCmdLine, _T("wmi_flag_mode")))
// Get wmi flag mode
m_pConfig->setWmiFlagMode(getParamValue(m_lpCmdLine, _T("wmi_flag_mode")));
// /DEFAULT_USER_DOMAIN[=user]
if (isRequired(m_lpCmdLine, _T("default_user_domain")))
// Get default user domain
m_pConfig->setDefaultUserDomain(getParamValue(m_lpCmdLine, _T("default_user_domain")));
return TRUE;
}
......@@ -55,6 +55,8 @@ void CConfig::Clear()
m_csIpDiscLat.Empty();
m_bFastIp = FALSE;
m_csVersion.Empty();
m_csWmiFlagMode = "COMPLETE";
m_csDefaultUserDomain.Empty();
}
LPCTSTR CConfig::getVersion()
......@@ -97,6 +99,36 @@ LPCTSTR CConfig::getLocalInventoryFolder()
return m_csLocal;
}
BOOL CConfig::isDefaultUserDomainRequired()
{
return !m_csDefaultUserDomain.IsEmpty();
}
LPCTSTR CConfig::getDefaultUserDomain()
{
return m_csDefaultUserDomain;
}
tag_WBEM_GENERIC_FLAG_TYPE CConfig::getWmiFlagMode()
{
CString m_csComplete("READ");
if (m_csWmiFlagMode == m_csComplete)
m_uFlag = WBEM_FLAG_DIRECT_READ;
else
m_uFlag = WBEM_FLAG_RETURN_WBEM_COMPLETE;
return m_uFlag;
}
LPCTSTR CConfig::getWmiFlagModeText()
{
CString m_csComplete("READ");
if (m_csWmiFlagMode == m_csComplete)
m_csFlag = "WBEM_FLAG_DIRECT_READ";
else
m_csFlag = "WBEM_FLAG_RETURN_WBEM_COMPLETE";
return m_csFlag;
}
BOOL CConfig::isNoTagRequired()
{
return m_bNoTag;
......@@ -191,6 +223,12 @@ BOOL CConfig::load( LPCTSTR lpstrFile)
GetPrivateProfileString( OCS_AGENT_SECTION, _T( "ComProvider"), OCS_DEFAULT_PROVIDER, csBuffer.GetBuffer( 1024), 1024, m_csConfigFile);
csBuffer.ReleaseBuffer();
setCommunicationProvider( csBuffer);
// Default user domain name
GetPrivateProfileString(OCS_AGENT_SECTION, _T("DEFAULT_USER_DOMAIN"), _T(""), m_csDefaultUserDomain.GetBuffer(1024), 1024, m_csConfigFile);
m_csDefaultUserDomain.ReleaseBuffer();
// WMI flag mode
GetPrivateProfileString(OCS_AGENT_SECTION, _T("WMI_FLAG_MODE"), _T(""), m_csWmiFlagMode.GetBuffer(1024), 1024, m_csConfigFile);
m_csWmiFlagMode.ReleaseBuffer();
return TRUE;
}
......@@ -219,6 +257,10 @@ BOOL CConfig::save( LPCTSTR lpstrFile)
bResult = bResult && WritePrivateProfileString( OCS_AGENT_SECTION, _T( "NoTAG"), csBuffer, m_csConfigFile);
// Force IP Discover for the specified network
bResult = bResult && WritePrivateProfileString( OCS_AGENT_SECTION, _T( "IpDisc"), m_csIpDisc, m_csConfigFile);
// Wmi flag mode
bResult = bResult && WritePrivateProfileString(OCS_AGENT_SECTION, _T("WMI_FLAG_MODE"), m_csWmiFlagMode, m_csConfigFile);
// Default user domain
bResult = bResult && WritePrivateProfileString(OCS_AGENT_SECTION, _T("DEFAULT_USER_DOMAIN"), m_csDefaultUserDomain, m_csConfigFile);
// Communication provider to use
CFile comFile( m_csComProvider, CFile::modeRead);
bResult = bResult && WritePrivateProfileString( OCS_AGENT_SECTION, _T( "ComProvider"), comFile.GetFileName(), m_csConfigFile);
......@@ -302,6 +344,16 @@ void CConfig::setNoTagRequired(BOOL bNoTag)
m_bNoTag = bNoTag;
}
void CConfig::setWmiFlagMode(LPCTSTR lpstrWmiFlag)
{
m_csWmiFlagMode = lpstrWmiFlag;
}
void CConfig::setDefaultUserDomain(LPCTSTR lpstrDefaultUserDomain)
{
m_csDefaultUserDomain = lpstrDefaultUserDomain;
}
void CConfig::setXmlFolder(LPCTSTR lpstrFolder)
{
if ((lpstrFolder == NULL) || (_tcslen( lpstrFolder) == 0))
......
......@@ -51,6 +51,7 @@ class CConfig;
#include "OCSInventory Front Classes.h"
#include "Singleton.h"
#include <OcsWmi.h>
class OCSINVENTORYFRONT_API CConfig : public CSingleton<CConfig>
{
......@@ -115,6 +116,12 @@ public: // Methods
BOOL isForceInventoryRequired();
// Get Communication Provider DLL
LPCTSTR getCommunicationProvider();
// Get Default User Domain
BOOL isDefaultUserDomainRequired();
LPCTSTR getDefaultUserDomain();
// Get WMI flag mode
tag_WBEM_GENERIC_FLAG_TYPE getWmiFlagMode();
LPCTSTR getWmiFlagModeText();
// Enable pr not debugging mode
void setDebugRequired( UINT uDebug = TRUE);
......@@ -147,6 +154,10 @@ public: // Methods
void setHkcuRequired( BOOL bHKCU = TRUE);
// Set Communication Provider DLL to use without extension .DLL
void setCommunicationProvider( LPCTSTR lpstrDll);
// Set WMI flag /WMI_FLAG_MODE=[READ/COMPLETE]
void setWmiFlagMode(LPCTSTR lpstrWmiFlag = LPCTSTR("COMPLETE"));
// Set Default user domain /DEFAULT_USER_DOMAIN=name
void setDefaultUserDomain(LPCTSTR lpstrDefaultUserDomain = NULL);
// Write Administrative info to admininfo.conf hidden file in agent install folder
BOOL writeAccountInfos( LPCTSTR lpstrName, LPCTSTR lpstrValue);
......@@ -170,6 +181,10 @@ private: //Attributes
CString m_csIpDiscLat; // Is /IPDISC_LAT:"number_of_ms" enabled to force IP Discover latency
BOOL m_bFastIp; // Is /FASTIP enabled, to disable network load contriol settings in IP Discover
CString m_csComProvider; // What's the communication provider to use to contact server ?
CString m_csWmiFlagMode; // READ or COMPLETE
tag_WBEM_GENERIC_FLAG_TYPE m_uFlag;
CString m_csDefaultUserDomain; // Default user domain name
CString m_csFlag;
// Agent version
CString m_csVersion;
};
......
......@@ -621,7 +621,8 @@ BOOL CInventoryRequest::runInventory()
CSoftware cSoftOS;
// Get logged on user
if (!m_pSysInfo->getUserName( cs1))
m_pLogger->log(LOG_PRIORITY_DEBUG, _T("INVENTORY => WMI FLAG MODE is set to <%s>"), getAgentConfig()->getWmiFlagModeText());
if (!m_pSysInfo->getUserName(cs1, getAgentConfig()->getWmiFlagMode()))
m_pLogger->log( LOG_PRIORITY_WARNING, _T( "INVENTORY => Failed to retrieve logged on user"));
else
m_pLogger->log( LOG_PRIORITY_DEBUG, _T( "INVENTORY => Logged on user ID is <%s>"), cs1);
......@@ -655,11 +656,18 @@ BOOL CInventoryRequest::runInventory()
cs1);
m_Device.SetDomainOrWorkgroup( cs1);
// Get NT user Domain
if (!m_pSysInfo->getUserDomain( cs1))
m_pLogger->log( LOG_PRIORITY_WARNING, _T( "INVENTORY => Failed to retrieve user domain"));
if (!getAgentConfig()->isDefaultUserDomainRequired())
{
if (!m_pSysInfo->getUserDomain(cs1, getAgentConfig()->getWmiFlagMode()))
m_pLogger->log(LOG_PRIORITY_WARNING, _T("INVENTORY => Failed to retrieve user domain"));
else
m_pLogger->log(LOG_PRIORITY_DEBUG, _T("INVENTORY => User domain is <%s>"), cs1);
}
else
m_pLogger->log( LOG_PRIORITY_DEBUG, _T( "INVENTORY => User domain is <%s>"),
cs1);
{
cs1 = getAgentConfig()->getDefaultUserDomain();
m_pLogger->log(LOG_PRIORITY_DEBUG, _T("INVENTORY => Default User domain is set to <%s>"), cs1);
}
m_Device.SetUserDomain( cs1);
// Get BIOS information
if (!m_pSysInfo->getBiosInfo( &m_BIOS))
......
......@@ -478,7 +478,7 @@ BOOL COcsWmi::GetClassObjectVariantValue( LPCTSTR lpstrProperty, VARIANT &pVal)
}
INT_PTR COcsWmi::GetRefElementClassObjectLength( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty)
INT_PTR COcsWmi::GetRefElementClassObjectLength( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
if (IsWindows8OrGreater())
{
......@@ -503,7 +503,7 @@ INT_PTR COcsWmi::GetRefElementClassObjectLength( LPCTSTR lpstrRefElement, LPCTST
if (csObject.IsEmpty())
return 0;
m_hResult = m_pIWbemServices->GetObject(_bstr_t(csObject),
WBEM_FLAG_RETURN_WBEM_COMPLETE,
m_uFlag,
NULL,
&pClassObject,
NULL);
......@@ -536,7 +536,7 @@ INT_PTR COcsWmi::GetRefElementClassObjectLength( LPCTSTR lpstrRefElement, LPCTST
}
}
BOOL COcsWmi::GetRefElementClassObjectVariantValue( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, VARIANT &pVal)
BOOL COcsWmi::GetRefElementClassObjectVariantValue( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, VARIANT &pVal, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
ASSERT( m_pClassObject);
ASSERT( lpstrRefElement);
......@@ -556,7 +556,7 @@ BOOL COcsWmi::GetRefElementClassObjectVariantValue( LPCTSTR lpstrRefElement, LPC
if (csObject.IsEmpty())
return FALSE;
m_hResult = m_pIWbemServices->GetObject( _bstr_t( csObject),
WBEM_FLAG_RETURN_WBEM_COMPLETE,
m_uFlag,
NULL,
&pClassObject,
NULL);
......@@ -584,7 +584,7 @@ BOOL COcsWmi::GetRefElementClassObjectVariantValue( LPCTSTR lpstrRefElement, LPC
}
LPCTSTR COcsWmi::GetRefElementClassObjectStringValue(LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty)
LPCTSTR COcsWmi::GetRefElementClassObjectStringValue(LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
ASSERT( m_pClassObject);
ASSERT( lpstrRefElement);
......@@ -606,7 +606,7 @@ LPCTSTR COcsWmi::GetRefElementClassObjectStringValue(LPCTSTR lpstrRefElement, LP
if (csObject.IsEmpty())
return NULL;
m_hResult = m_pIWbemServices->GetObject( _bstr_t( csObject),
WBEM_FLAG_RETURN_WBEM_COMPLETE,
m_uFlag,
NULL,
&pClassObject,
NULL);
......@@ -638,7 +638,7 @@ LPCTSTR COcsWmi::GetRefElementClassObjectStringValue(LPCTSTR lpstrRefElement, LP
}
DWORD COcsWmi::GetRefElementClassObjectDwordValue(LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty)
DWORD COcsWmi::GetRefElementClassObjectDwordValue(LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
ASSERT( m_pClassObject);
ASSERT( lpstrRefElement);
......@@ -661,7 +661,7 @@ DWORD COcsWmi::GetRefElementClassObjectDwordValue(LPCTSTR lpstrRefElement, LPCTS
if (csObject.IsEmpty())
return 0;
m_hResult = m_pIWbemServices->GetObject( _bstr_t( csObject),
WBEM_FLAG_RETURN_WBEM_COMPLETE,
m_uFlag,
NULL,
&pClassObject,
NULL);
......@@ -688,7 +688,7 @@ DWORD COcsWmi::GetRefElementClassObjectDwordValue(LPCTSTR lpstrRefElement, LPCTS
}
__int64 COcsWmi::GetRefElementClassObjectI64Value(LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty)
__int64 COcsWmi::GetRefElementClassObjectI64Value(LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
ASSERT( m_pClassObject);
ASSERT( lpstrRefElement);
......@@ -711,7 +711,7 @@ __int64 COcsWmi::GetRefElementClassObjectI64Value(LPCTSTR lpstrRefElement, LPCTS
if (csObject.IsEmpty())
return 0;
m_hResult = m_pIWbemServices->GetObject( _bstr_t( csObject),
WBEM_FLAG_RETURN_WBEM_COMPLETE,
m_uFlag,
NULL,
&pClassObject,
NULL);
......@@ -738,7 +738,7 @@ __int64 COcsWmi::GetRefElementClassObjectI64Value(LPCTSTR lpstrRefElement, LPCTS
}
unsigned __int64 COcsWmi::GetRefElementClassObjectU64Value(LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty)
unsigned __int64 COcsWmi::GetRefElementClassObjectU64Value(LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
ASSERT( m_pClassObject);
ASSERT( lpstrRefElement);
......@@ -761,7 +761,7 @@ unsigned __int64 COcsWmi::GetRefElementClassObjectU64Value(LPCTSTR lpstrRefEleme
if (csObject.IsEmpty())
return 0;
m_hResult = m_pIWbemServices->GetObject( _bstr_t( csObject),
WBEM_FLAG_RETURN_WBEM_COMPLETE,
m_uFlag,
NULL,
&pClassObject,
NULL);
......
......@@ -62,23 +62,23 @@ public:
// Get Length of data in object
INT_PTR GetClassObjectLength( LPCTSTR lpstrProperty);
INT_PTR GetRefElementClassObjectLength( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty);
INT_PTR GetRefElementClassObjectLength( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
// Get current enumerated object properties (or properties of an objet referenced by the current enumerated object)
LPCTSTR GetClassObjectStringValue( LPCTSTR lpstrProperty);
LPCTSTR GetRefElementClassObjectStringValue( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty);
LPCTSTR GetRefElementClassObjectStringValue( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
DWORD GetClassObjectDwordValue( LPCTSTR lpstrProperty);
DWORD GetRefElementClassObjectDwordValue( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty);
DWORD GetRefElementClassObjectDwordValue( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
__int64 GetClassObjectI64Value( LPCTSTR lpstrProperty);
__int64 GetRefElementClassObjectI64Value( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty);
__int64 GetRefElementClassObjectI64Value( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
unsigned __int64 GetClassObjectU64Value( LPCTSTR lpstrProperty);
unsigned __int64 GetRefElementClassObjectU64Value( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty);
unsigned __int64 GetRefElementClassObjectU64Value( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
BOOL GetClassObjectVariantValue( LPCTSTR lpstrProperty, VARIANT &pVal);
BOOL GetRefElementClassObjectVariantValue( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, VARIANT &pVal);
BOOL GetRefElementClassObjectVariantValue( LPCTSTR lpstrRefElement, LPCTSTR lpstrProperty, VARIANT &pVal, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
HRESULT GetLastErrorWMI();
......
......@@ -636,7 +636,7 @@ BOOL CSysInfo::isNotebook()
}
BOOL CSysInfo::getUserName(CString &csUserName)
BOOL CSysInfo::getUserName(CString &csUserName, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
TCHAR szUserName[255];
DWORD dwUserName = 255;
......@@ -657,7 +657,7 @@ BOOL CSysInfo::getUserName(CString &csUserName)
See https://bugs.launchpad.net/ocsinventory-windows-agent/+bug/1300172
*/
if (m_wmiInfo.IsConnected() && m_wmiInfo.GetLoggedOnUser( csUserName))
if (m_wmiInfo.IsConnected() && m_wmiInfo.GetLoggedOnUser( csUserName, m_uFlag))
return TRUE;
// Call the GetUserName function.
AddLog( _T( "GetUserName: Trying to find logged on User ID from current running process...\n"));
......@@ -862,10 +862,10 @@ BOOL CSysInfo::getDomainOrWorkgroup(CString &csDomain)
return m_registryInfo.GetDomainOrWorkgroup( csDomain);
}
BOOL CSysInfo::getUserDomain(CString &csUserDomain)
BOOL CSysInfo::getUserDomain(CString &csUserDomain, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
// First, try WMI
if (m_wmiInfo.GetUserDomain( csUserDomain))
if (m_wmiInfo.GetUserDomain( csUserDomain, m_uFlag))
return TRUE;
// Last, use registry
return m_registryInfo.GetDomainOrWorkgroup( csUserDomain);
......
......@@ -106,7 +106,7 @@ public: // Methods
BOOL getOS( CString &csName, CString &csVersion, CString &csComment, CString &csDescription, CString &csInstallDate);
DWORD getAddressWidthOS();
BOOL getDomainOrWorkgroup( CString &csDomain);
BOOL getUserDomain( CString &csUserDomain);
BOOL getUserDomain( CString &csUserDomain, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
// Memory information
BOOL getMemory( ULONG *m_ulPhysicalMemory, ULONG *m_ulSwapSize);
......@@ -133,7 +133,7 @@ public: // Methods
BOOL isNotebook();
// User information
BOOL getUserName( CString &csUserName);
BOOL getUserName( CString &csUserName, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
BOOL getUserNameFromExplorerProcess( CString &csUserName);
// Last user logged in the system
......
......@@ -1023,7 +1023,7 @@ BOOL CWmi::GetVideoAdapters(CVideoAdapterList *pMyList)
}
}
BOOL CWmi::GetNetworkAdapters(CNetworkAdapterList *pMyList)
BOOL CWmi::GetNetworkAdapters(CNetworkAdapterList *pMyList, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
ASSERT( pMyList);
......@@ -1047,29 +1047,29 @@ BOOL CWmi::GetNetworkAdapters(CNetworkAdapterList *pMyList)
while (m_dllWMI.MoveNextEnumClassObject())
{
myObject.Clear();
lIfIndex = m_dllWMI.GetRefElementClassObjectDwordValue( _T( "Element"), _T( "InterfaceIndex"));
lIfIndex = m_dllWMI.GetRefElementClassObjectDwordValue( _T( "Element"), _T( "InterfaceIndex"), m_uFlag);
myObject.SetIfIndex( lIfIndex);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "AdapterType"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "AdapterType"), m_uFlag);
myObject.SetType( csBuffer);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "ProductName"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "ProductName"), m_uFlag);
myObject.SetDescription( csBuffer);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Speed"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Speed"), m_uFlag);
myObject.SetSpeed( csBuffer);
csMacAddress = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "MACAddress"));
csMacAddress = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "MACAddress"), m_uFlag);
myObject.SetMACAddress( csMacAddress);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "IPAddress"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "IPAddress"), m_uFlag);
myObject.SetIPAddress( csBuffer);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "IPSubnet"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "IPSubnet"), m_uFlag);
myObject.SetIPNetMask( csBuffer);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DefaultIPGateway"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DefaultIPGateway"), m_uFlag);
myObject.SetGateway( csBuffer);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DHCPServer"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DHCPServer"), m_uFlag);
myObject.SetDhcpServer( csBuffer);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue(_T("Setting"), _T("MTU"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue(_T("Setting"), _T("MTU"), m_uFlag);
myObject.SetMtu(csBuffer);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Status"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Status"), m_uFlag);
myObject.SetStatus( csBuffer);
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "AdapterType"));
csBuffer = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Element"), _T( "AdapterType"), m_uFlag);
myObject.SetTypeMIB( csBuffer);
AddLog( _T( "\t\t<IfIndex: %ld><Type: %s><Description: %s><Speed: %s><MAC: %s><IP Address: %s><IP Subnet: %s><Gateway: %s><DHCP: %s><Status: %s><TypeMIB: %s><MTU: %s>\n"),
myObject.GetIfIndex(), myObject.GetType(), myObject.GetDescription(), myObject.GetSpeed(),
......@@ -1835,7 +1835,7 @@ BOOL CWmi::GetDomainOrWorkgroup( CString &csDomain)
}
BOOL CWmi::GetLoggedOnUser( CString &csUser)
BOOL CWmi::GetLoggedOnUser( CString &csUser, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
// If not WMI connected => cannot do this
if (!m_bConnected)
......@@ -1850,10 +1850,10 @@ BOOL CWmi::GetLoggedOnUser( CString &csUser)
{
while (m_dllWMI.MoveNextEnumClassObject())
{
if (m_dllWMI.GetRefElementClassObjectDwordValue( _T( "Dependent"), _T( "LogonType")) == 2)
if (m_dllWMI.GetRefElementClassObjectDwordValue( _T( "Dependent"), _T( "LogonType"), m_uFlag) == 2)
{
// This is an interactive session
csUser = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Antecedent"), _T( "Name"));
csUser = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Antecedent"), _T( "Name"), m_uFlag);
AddLog( _T( "\t\t<User: %s>\n"), csUser);
uIndex++;
}
......@@ -1876,7 +1876,7 @@ BOOL CWmi::GetLoggedOnUser( CString &csUser)
return FALSE;
}
BOOL CWmi::GetUserDomain( CString &csDomain)
BOOL CWmi::GetUserDomain( CString &csDomain, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag)
{
BOOL bResult = FALSE;
......@@ -1893,10 +1893,10 @@ BOOL CWmi::GetUserDomain( CString &csDomain)
{
while (m_dllWMI.MoveNextEnumClassObject())
{
if (m_dllWMI.GetRefElementClassObjectDwordValue( _T( "Dependent"), _T( "LogonType")) == 2)
if (m_dllWMI.GetRefElementClassObjectDwordValue( _T( "Dependent"), _T( "LogonType"), m_uFlag) == 2)
{
// This is an interactive session
csDomain = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Antecedent"), _T( "Domain"));
csDomain = m_dllWMI.GetRefElementClassObjectStringValue( _T( "Antecedent"), _T( "Domain"), m_uFlag);
AddLog( _T( "\t\t<Domain: %s>\n"), csDomain);
uIndex++;
}
......
......@@ -49,8 +49,8 @@ public: // Methods
BOOL GetOS( CString &csName, CString &csVersion, CString &csComment, CString &csDescription, CString &csInstallDate);
DWORD GetAddressWidthOS();
BOOL GetDomainOrWorkgroup(CString &csDomain);
BOOL GetLoggedOnUser( CString &csUser);
BOOL GetUserDomain(CString &csDomain);
BOOL GetLoggedOnUser( CString &csUser, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
BOOL GetUserDomain(CString &csDomain, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
BOOL GetInputDevices( CInputDeviceList *pMyList);
BOOL GetSystemPorts( CSystemPortList *pMyList);
BOOL GetPrinters( CPrinterList *pMyList);
......@@ -60,7 +60,7 @@ public: // Methods
BOOL GetMemorySlots( CMemorySlotList *pMyList);
BOOL GetModems( CModemList *pMyList);
BOOL GetMonitors( CMonitorList *pMyList);
BOOL GetNetworkAdapters( CNetworkAdapterList *pMyList);
BOOL GetNetworkAdapters( CNetworkAdapterList *pMyList, tag_WBEM_GENERIC_FLAG_TYPE m_uFlag);
BOOL GetSoundDevices( CSoundDeviceList *pMyList);
BOOL GetStoragePeripherals( CStoragePeripheralList *pMyList);
BOOL GetSystemControllers( CSystemControllerList *pMyList);
......
......@@ -1656,75 +1656,75 @@ void CTestSysInfoDlg::OnBnClickedWmi()
CString str, res;
str = _T( "InterfaceIndex = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "InterfaceIndex"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "InterfaceIndex"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "AdapterType = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "AdapterType"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "AdapterType"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "ProductName = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "ProductName"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "ProductName"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "MaxSpeed = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Speed"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Speed"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "Manufacturer = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Manufacturer"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Manufacturer"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "Caption = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Caption"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Caption"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "Description = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Description"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Description"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "MACAddress = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "MACAddress"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "MACAddress"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "IPAddress = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "IPAddress"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "IPAddress"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "IPSubnet = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "IPSubnet"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "IPSubnet"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "DefaultIPGateway = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DefaultIPGateway"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DefaultIPGateway"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "DNSDomain = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DNSDomain"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DNSDomain"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "DNSSearchOrder = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DNSSearchOrder"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DNSSearchOrder"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "DHCPEnabled = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DHCPEnabled"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DHCPEnabled"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "DHCPServer = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DHCPServer"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Setting"), _T( "DHCPServer"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "Status = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Status"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "Status"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "NetConnectionStatus = ");
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "NetConnectionStatus"));
res = myWmiDll.GetRefElementClassObjectStringValue( _T( "Element"), _T( "NetConnectionStatus"), WBEM_FLAG_RETURN_WBEM_COMPLETE);
str += res;
m_List.AddString( str);
str = _T( "IPEnabled = ");
res.Format( _T( "%lu"), myWmiDll.GetRefElementClassObjectDwordValue( _T( "Setting"), _T( "IPEnabled")));
res.Format( _T( "%lu"), myWmiDll.GetRefElementClassObjectDwordValue( _T( "Setting"), _T( "IPEnabled"), WBEM_FLAG_RETURN_WBEM_COMPLETE));
str += res;
m_List.AddString( str);
m_List.AddString( _T( ""));
......@@ -2965,7 +2965,7 @@ BOOL CTestSysInfoDlg::runSysInfo()
CSysInfo mySysInfo( TRUE, szTempPath);
// Get logged on user
if (!mySysInfo.getUserName( cs1))
if (!mySysInfo.getUserName( cs1, WBEM_FLAG_RETURN_WBEM_COMPLETE))
AfxMessageBox( _T( "Failed to get username !"));
m_Device.SetLoggedOnUser( cs1);
// Last logged on user
......@@ -2987,7 +2987,7 @@ BOOL CTestSysInfoDlg::runSysInfo()
AfxMessageBox( _T( "Failed to get Domain or Workgroup information !"));
m_Device.SetDomainOrWorkgroup( cs1);
// Get NT user Domain
if (!mySysInfo.getUserDomain( cs1))
if (!mySysInfo.getUserDomain( cs1, WBEM_FLAG_RETURN_WBEM_COMPLETE))
AfxMessageBox( _T( "Failed to get User Domain information !"));
m_Device.SetUserDomain( cs1);
// Get BIOS information
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment