Click to See Complete Forum and Search --> : WMI Connection Error to remote machine


sa125
July 8th, 2008, 03:31 AM
Hi - I'm trying to use WMI to query a remote machine and get process information. Locally my program worked great, but the remote connection gives me a ManagementException "user credentials cannot be used for local connections." Here is my code:

using System.Management;
//....
ManagementScope scope = new ManagementScope(new ManagementPath("\\\\xp-remote02"));
scope.Options.user = "mike";
scope.Options.Password= "tike";
scope.Options.Authentication= AuthenticationLevel.PacketPrivacy;
// Formulate the query - SELECT * FROM Win32_Process WHERE Name LIKE "%dev%"
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Process WHERE Name LIKE \"%dev%\"");

//Execute the query
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);

//Get the results
ManagementObjectCollection collection = searcher.Get();

//loop and write to console
foreach( ManagementObject mgt in collection)
{
Console.WriteLine(mgt["Name"].ToString());
}

//....

The error points to the row containing searcher.Get(). I'd really appreciate help on this one - thanks.

sa125
July 8th, 2008, 04:14 AM
Is it even possible to remote connect or am I just waiting my time? Why do I keep getting that error?...

Thread1
July 8th, 2008, 06:39 AM
it is obvious in the error message that your computer has no admin rights (policy) to access remote computers' in your network area. checkout with your network admin, he should provide you with the right GPO ;)

sa125
July 11th, 2008, 03:34 AM
I have access to the remote machine via remote-desktop-connection (as simple user). Does that mean I can't access it with WMI unless I have admin privileges?