J
JohnBates
I'm trying to (programatically) backup and clear the security event log on
the local machine. I can do this manually through the event viewer and I am
logged on as an administrator. I can successfully connect to the local wmi
service. I can step through and list all the log files on the local computer
in a text box so I know I can get an System.Management.ManagementObject that
is the security log.
However when I try to execute the "BackupEventLog" method I get access
denied.
Here is my code for trying to execute the method:
logfileSearcher = New
System.Management.ManagementObjectSearcher(myManagementScope.Path.ToString,
"Select * from win32_NTEventLogFile WHERE LogFileName='security'")
'* execute query
'* Get Event Log Files
logfiles = logfileSearcher.Get()
For Each logfile In logfiles
Dim inParams As Management.ManagementBaseObject =
logfile.GetMethodParameters("BackupEventLog")
inParams("ArchiveFileName") = "c:\testing.evt"
Dim outParams As Management.ManagementBaseObject =
logfile.InvokeMethod("BackupEventLog", inParams, Nothing)
Next
Here is the error detail:
Error Encountered: System.Management.ManagementException: Access denied
at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode)
at System.Management.ManagementObject.InvokeMethod(String methodName,
ManagementBaseObject inParameters, InvokeMethodOptions options)
at wmitest.Form1.Button3_Click(Object sender, EventArgs e) in
C:\Documents and Settings\1069317\Desktop\Desktop
Stuff\JTSecuAudit\wmitest\Form1.vb:line 75
I have checked around on google and found that several people have had
similar issues and it has to do with the privileges of the wmi connection. I
am logged onto the machine as an administrator, I have also set the
ConnectionOptions.EnablePrivileges = True
But it does not work...I have found threads online indicating that setting
EnablePrivileges to True worked on .NET framework 1.0 but it "stopped"
working on 1.1 and I assume doesn't work on 2.0 as I am having this issue.
(I am using .NET Framework 2.0 SP1).
please help!
the local machine. I can do this manually through the event viewer and I am
logged on as an administrator. I can successfully connect to the local wmi
service. I can step through and list all the log files on the local computer
in a text box so I know I can get an System.Management.ManagementObject that
is the security log.
However when I try to execute the "BackupEventLog" method I get access
denied.
Here is my code for trying to execute the method:
logfileSearcher = New
System.Management.ManagementObjectSearcher(myManagementScope.Path.ToString,
"Select * from win32_NTEventLogFile WHERE LogFileName='security'")
'* execute query
'* Get Event Log Files
logfiles = logfileSearcher.Get()
For Each logfile In logfiles
Dim inParams As Management.ManagementBaseObject =
logfile.GetMethodParameters("BackupEventLog")
inParams("ArchiveFileName") = "c:\testing.evt"
Dim outParams As Management.ManagementBaseObject =
logfile.InvokeMethod("BackupEventLog", inParams, Nothing)
Next
Here is the error detail:
Error Encountered: System.Management.ManagementException: Access denied
at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode)
at System.Management.ManagementObject.InvokeMethod(String methodName,
ManagementBaseObject inParameters, InvokeMethodOptions options)
at wmitest.Form1.Button3_Click(Object sender, EventArgs e) in
C:\Documents and Settings\1069317\Desktop\Desktop
Stuff\JTSecuAudit\wmitest\Form1.vb:line 75
I have checked around on google and found that several people have had
similar issues and it has to do with the privileges of the wmi connection. I
am logged onto the machine as an administrator, I have also set the
ConnectionOptions.EnablePrivileges = True
But it does not work...I have found threads online indicating that setting
EnablePrivileges to True worked on .NET framework 1.0 but it "stopped"
working on 1.1 and I assume doesn't work on 2.0 as I am having this issue.
(I am using .NET Framework 2.0 SP1).
please help!