Re: WMI Query against remote machine. Access issues

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Apr 14, 11:27 am, a...@xxxxxxxxx wrote:
I am trying to query a service and perf mon counters on a remote
machine.

My code is as below.

ConnectionOptions opt = new ConnectionOptions();
                opt.Impersonation = ImpersonationLevel.Impersonate;
                opt.Timeout = new TimeSpan(0, 0, 30);

                ManagementScope scope = new
ManagementScope(String.Format(@"\\{0}\root\cimv2", "TRLW16628"), opt);

                scope.Connect();

                if (scope.IsConnected)
                {

                    //Select the SMTP Service
                    ObjectQuery query = new ObjectQuery("SELECT * FROM
Win32_Service WHERE Name = 'SMTPSVC'");
                    ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query);

                    //Loop through the collection and if the service
is started, set result to true
                    foreach (ManagementObject service in
searcher.Get())
                    {
                        Console.WriteLine("Service started = " +
service.Properties["Started"].Value);
                    }
                }

and the perfmon query is SELECT * FROM
Win32_PerfFormattedData_SMTPSVC_SMTPServer

When I add my username to the local admin group on the remote computer
(TRLW16628) everything works fine.

I dont want to give admin rights to the user so instead, I have given
full rights to my user to root, and I have also given my user DCOM
remote launch and activation permissions.. but still no joy.

Through wbemtest.exe I get 0x80041003 Access Denied,

and in my code i get

System.Management.ManagementException: Access denied
   at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStat
us errorCode)
   at System.Management.ManagementScope.InitializeGuts(Object o)
   at System.Management.ManagementScope.Initialize()
   at System.Management.ManagementScope.Connect()
   at WMITestConsole.Program.Main(String[] args) in C:\Documents and
Settings\de
saia1\My Documents\Visual Studio 2005\Projects\WMITestConsole
\WMITestConsole\Pro
gram.cs:line 22

Anyone have any ideas

Ok I have got a bit further with this one..

I add applied permissions to the root name space and not the root
\cimv2 having corrected that.. I can now connect to the remote
computer, but the actual query still fails with the following
exception

System.Management.ManagementException: Generic failure
at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStat
us errorCode)
at
System.Management.ManagementObjectCollection.ManagementObjectEnumerator.Mo
veNext()
at WMITestConsole.Program.Main(String[] args) in C:\Documents and
Settings\de
saia1\My Documents\Visual Studio 2005\Projects\WMITestConsole
\WMITestConsole\Pro
gram.cs:line 29
.



Relevant Pages

  • Re: Query In BE database
    ... What Is A Remote Query? ... point your local query to a query that was in another Access database. ... queries and that is remote queries. ...
    (microsoft.public.access.queries)
  • Re: Strange perf.
    ... HASH JOIN 72 6 K 132 ... REMOTE 30 K 2 M 72 CBDSRV_SRVCNS.WORLD SERIAL ... In the quick query the join is a hash join, ... will be executing about 30,000 queries ...
    (comp.databases.oracle.server)
  • Re: Strange perf.
    ... HASH JOIN 72 6 K 132 ... REMOTE 30 K 2 M 72 CBDSRV_SRVCNS.WORLD SERIAL ... In the quick query the join is a hash join, ... will be executing about 30,000 queries ...
    (comp.databases.oracle.server)
  • Re: Size of Query result
    ... update of my remote display has not always worked. ... But this problem that the query result cannot be set, ... button on a form that would refresh the links on the remote computer. ... Rolf Rosenquist wrote: ...
    (microsoft.public.access.queries)
  • Re: Query In BE database
    ... In the table is a list of all the queries that are available to be selected. ... When selected from the drop-down list box, I what the the query that is being ... What Is A Remote Query? ... point your local query to a query that was in another Access database. ...
    (microsoft.public.access.queries)