WMI + DCOM + VPN ...Slow -
08-29-2007
, 05:52 AM
Any help with this topic woud be appreciated greatly. I am using WMI
over VPN.
The authentication takes > 30 seconds. Way toooo slow. [Crunch
below]. Inside the corporate LAN yesterday this connection was < 2
seconds. Included full code below. Is the oConn.Impersonation =
ImpersonationLevel.Impersonate correct ?
All suggestions welcome.
Many thanks.
sWMIQuery= Select * from Win32_NTLogEvent Where LogFile='Application'
and TimeGenerated >='20070813170102.000000+060'";
public ArrayList GetEvents(string sWMIQuery, string
sMachineName,string sUserName,string sPassword)
{
try
{
ManagementObjectSearcher searcher = null;
string sNameSpace = "root\\cimv2";
ArrayList foundEntries = new ArrayList();
System.Management.ManagementScope oMs = new
System.Management.ManagementScope("\\\\" + sMachineName + "\\" +
sNameSpace);
ConnectionOptions oConn = new
ConnectionOptions();
oConn.Username = sUserName;
oConn.Password = sPassword;
oConn.Impersonation =
ImpersonationLevel.Impersonate;
oMs.Connect(); ///Crunch
searcher = new
ManagementObjectSearcher(sWMIQuery);
searcher.Get();
searcher.Scope = oMs;
int counter = 0;
//returns the records
foreach (ManagementObject Event in
searcher.Get())
{
counter = counter + 1;
//Some of the Messages are NULL when viewed
thru WMI CIM Studio - must check for these
if (Event.Properties["Message"].Value !=
null)
{
WMIEvent wmiEvent = new WMIEvent(
Event.Properties["Message"].Value.ToString(),
Event.Properties["Type"].Value.ToString(),
Event.Properties["LogFile"].Value.ToString());
foundEntries.Add(wmiEvent);
}
}
return foundEntries;
} |