Re: Access Denied on a ManagementEventWatcher to Remote System
- From: Carl Klouda <CarlKlouda@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 7 Aug 2006 07:12:02 -0700
I've already tried all authentication levels with no success. I switched
from Asynchronous processing (_watcher.Start() ) to synchronous
(_watcher.WaitForNextEvent ) and that has resolved the issue. I'd prefer to
do asynchronous processing, but based on all the internet posts and msdn
posts it is just way too much of a hassle because of the reverse connections,
firewalls, credentials passing across threads, etc...
Seems like it shouldn't be that hard.
"mabra" wrote:
Hi !.
Ok, try:
scope.Options.Impersonation = ImpersonationLevel.Impersonate;
scope.Options.Authentication = AuthenticationLevel.Connect;
Let's see, if this helps.
I can offer to send you a working C# sample, if you mail me.
Best regards,
Manfred
mabra AT manfbraun.<country>
[my country is de] ;-)
Carl Klouda wrote:
Thanks for the response:
I set the event handler by declaring _watcher "withevents" and then if you
notice the SecurityArrivedEventHandler "Handles _watcher.EventArrived"
I re-read my post and admit that it was confusing. What I meant was that if
I installed and ran the application on the remote device, of course without
the credential information, it works fine. If I try to run the application
on my PC with the managementpath pointed to the remote device and specify
credentials, it does not work.
I have tried EnablePrivileges and supplied an administrator user account in
the form domain\userid. It still did not work. I've also tried setting the
authentication modes to packet, packetpricvacy, and connect with no luck.
"mabra" wrote:
Hi !
Some notes.
This code cannot run locally, because you are specifying credentials.
I see no source, which set's the eventhandler.
I would recommend to try two things:
a) scope.Options.EnablePrivileges = True
b) use 'scope.Options.Username = "remoteserver\adminuser"'
May be this helps.
Best regards,
Manfred
Carl Klouda wrote:
Been struggling to get a managementeventwatcher working for a remote system.
Running the app on a WinXP system. I've tried to connect to Windows 2000 and
Windows 2003.
The app is simple and just monitors/queries the System Event log on a remote
system. Works fine if you run it on the remote system directly without
credentials. The user id and pwd I use for the remote connections is a local
admin on the remote system.
My code is below. (Note that scope.Connect() works fine, but
_watcher.Start() returns the access denied)
'//////////////////////////////////////////////////////////////////////////////////
Imports System
Imports System.Management
Public Class SecWatcher
Private WithEvents _watcher As ManagementEventWatcher
Public Sub Start()
Dim scope As New ManagementScope("\\remoteserver\root\cimv2")
scope.Options.Username = "adminuser"
scope.Options.Password = "adminpass"
scope.Options.Impersonation = ImpersonationLevel.Impersonate
scope.Connect()
Dim wql As New WqlEventQuery("SELECT * FROM __InstanceCreationEvent
WITHIN 3 WHERE TargetInstance ISA 'Win32_NTLogEvent' and
TargetInstance.LogFile = 'System'")
_watcher = New ManagementEventWatcher()
_watcher.Query = wql
_watcher.Scope = scope
_watcher.Start()
End Sub
Public Sub [Stop]()
_watcher.Stop()
End Sub
Private Sub SecurtyEventArrivedHandler(ByVal sender As Object, ByVal e
As EventArrivedEventArgs) Handles _watcher.EventArrived
Console.WriteLine(DateTime.Now.ToString & " -- " &
CType(e.NewEvent("TargetInstance"), ManagementBaseObject)("ComputerName") & "
-- " & CType(e.NewEvent("TargetInstance"), ManagementBaseObject)("Message"))
End Sub
End Class
- Follow-Ups:
- References:
- Prev by Date: Re: Setting ComputerSystem class Parameters
- Next by Date: Re: Recognize situation :CPU USAGE 0%,all windows are not responding when IEXPLORE waiting for timeout(or searching the net)
- Previous by thread: Re: Access Denied on a ManagementEventWatcher to Remote System
- Next by thread: Re: Access Denied on a ManagementEventWatcher to Remote System
- Index(es):
Relevant Pages
|
Loading