0

When I am executing the following code to the local machine, it works fine:

string eventLogName = "Security";
string sourceName = "BTHUSB";
string machineName = "Venus";
EventLog eventLog;
eventLog = new EventLog();
eventLog.Log = eventLogName;
eventLog.Source = sourceName;
eventLog.MachineName = machineName;

foreach (EventLogEntry e in eventLog.Entries)
{
    Console.WriteLine("Entry type :{0}",e.EntryType);
}

When I am executing above code it does not execute it gives an error as:

Attempted to perform an unauthorized operation

How to solve it?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Gomathipriya
  • 905
  • 7
  • 19
  • 38

1 Answers1

1

Run the code under a user who has local admin permissions on remote machine.

abatishchev
  • 98,240
  • 88
  • 296
  • 433