0

I need to read from the security log in windows, but the user will not have the administrative permissions to do so, and the application will throw an exception,

EventLog[] a = EventLog.GetEventLogs();

foreach (var item in a)
{
    if (item.Log == "Security")
    {               
        foreach (EventLogEntry item2 in item.Entries)//The exception thrown here
        {
            //TODO
        }
    }
}

I just want to read, I don't want to write anything. How to gain access to these entries without those permissions?

Jeff LaFay
  • 12,882
  • 13
  • 71
  • 101
Abdallah Nasir
  • 607
  • 6
  • 33
  • 2
    I know nothing about it, but I'd be surprised if you could. That's the point of having security levels - the user and their software can only do what they're permitted to do. What do you need out of the security log? It's possible that there's another way to get at the specific information you need. – Bobson Nov 21 '12 at 14:00
  • This is most likely a http://superuser.com question because that is a permissions problem and not a development problem. – Jeff LaFay Nov 21 '12 at 14:03
  • if it is not a problem, I wouldn't ask :) beside, if there is a way I can change the log settings using .NET code or .bat files my problem will be solved since I can run an application as administrator so I may change everything, if possible of course,, Thanks for help – Abdallah Nasir Nov 21 '12 at 14:24
  • @AbdallahNasir - What do you need to read from the log? – Bobson Nov 21 '12 at 15:06
  • @AbdallahNasir - Yeah, that's a good reason. I can't help, but good luck! – Bobson Nov 23 '12 at 15:13
  • I could read Time change event from system log, which does not requires permissions, but still I cannot do that on XP, anyways, I can tell my problem solved. Thanks everybody :) – Abdallah Nasir Nov 25 '12 at 06:31

1 Answers1

2

There is a possibility but it requires extensive steps by a qualified Administrator to set up the necessary rights. For more info, see http://blogs.technet.com/b/janelewis/archive/2010/04/30/giving-non-administrators-permission-to-read-event-logs-windows-2003-and-windows-2008.aspx.

If you do not explicitly get rights to read, you cannot -- that is the whole point of DRM.

Roy Dictus
  • 32,551
  • 8
  • 60
  • 76
  • To tell the truth, I understood almost nothing from the link, but, my application requires one time run as admin, and I can ensure that, if it is possible to configure the system with the links you gave me using .NET and .bat files I will study the article even if takes a week? so, can we done these steps using .NET code and .bat files :) ? Thanks a lot – Abdallah Nasir Nov 21 '12 at 14:20