title: EventLog write permissions
body: <p>My question is related to write permissions to the Windows Event Log.
  I have looked around several posts concering this, and have found some ways to solve my problem, but none of these are acceptable for my current scenario.</p>
  
  <p>I use C# in .NET 4.0. I use the EventLog class:
  <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx">EventLog class</a></p>
  
  <p>In short, I need to see if there is a way to impersonate or authenticate with an authenticated user and password to reach the right I need to write to the Event Log. The server will always be in the Windows Server family, but the version may vary.</p>
  
  <p>My application is a Windows Service running with one of the following accounts:</p>
  
  <ul>
  <li>Network Service</li>
  <li>Local Service</li>
  <li>Local System</li>
  <li>User with restricted rights (Users or
  Domain Users groups)</li>
  </ul>
  
  <p>Here are some other criterias I have:</p>
  
  <ul>
  <li>I cannot put the service user as Administrator, not even local administrator on the server</li>
  <li><strong>I cannot edit or alter the registry</strong></li>
  <li>I cannot alter the UAC or any group policies on the server</li>
  <li>I have a user with Administrator rights, but <strong>it cannot be used to run the service</strong></li>
  <li>The Event Log will always be the local Event Log, not on a remote machine</li>
  <li>The Log will probably always be the "Application" log</li>
  <li><strong>The Source may vary</strong>, and that seems to be the heart of the problem</li>
  </ul>
  
  <p>My question is : <strong>Is this at all possible?</strong></p>
  
  <p>Can I impersonate a user in my code to achieve what I need?
  I do that when connecting to web services, logging on to smtp servers and of courseclogging in to databases etc.</p>
  
  <p>I stumbled into this class:
  <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlogpermission.aspx">EventLogPermission Class</a></p>
  
  <p>But I cannot seem to get a good concept on how to use the class.</p>
  
  <p>I hope I have expressed my problem good. I don't concider this a duplicate of another post because of my criterias.</p>