Access Right for Perlscript to Read Windows EventLog Remotely

Discussion in 'Perl' started by Joe, Sep 29, 2003.

  1. Joe

    Joe Guest

    I am trying to read the EventLog of different servers on the network. If I
    run the script in a command line, it works well. But when I try to put the
    script into the Web server (IIS in Windows 2000) and run from a web browser,
    it works with my local machine only. I have the following error when I try
    to access any remote server:

    CGI Error
    The specified CGI application misbehaved by not returning a complete set of
    HTTP headers. The headers it did return are:
    Can't get number of Eventlog records

    I think it is a permission issue related to IIS. I have already given local
    admin's right to the account for running applications in Web and logging on
    to the web server (ISUR_web01 & IWAN_web01). Also, I changed the account
    for starting up the Web server to a domain admin's account from a system
    account. But still I cannot make it work.

    Any help would be appreciated.

    Joe






    #=============================
    use Win32::EventLog;

    # put in server name; it works for local server,
    # but not any remote machines, have to fix it.

    my $servername = "\\server1";


    $handle=Win32::EventLog->new("System", $servername")
    or die "Can't open Application EventLog\n";
    $handle->GetNumber($recs)
    or die "Can't get number of EventLog records\n";
    $handle->GetOldest($base)
    or die "Can't get number of oldest EventLog record\n";

    print "Content-type: text/html\n\n";
    print "<HTML>\n<BODY>\n<H3>\n\n";

    while ($x < $recs) {
    $handle->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ,
    $base+$x,
    $hashRef)
    or die "Can't read EventLog entry #$x\n";
    if ($hashRef->{Source} eq "EventLog") {
    Win32::EventLog::GetMessageText($hashRef);
    print "Entry $x: $hashRef->{Message}<P>\n";
    }
    $x++;
    }

    print "</H3>\n</BODY></HTML>";
     
    Joe, Sep 29, 2003
    #1
    1. Advertising

  2. Joe

    Thomas Kratz Guest

    Joe wrote:

    > I am trying to read the EventLog of different servers on the network. If I
    > run the script in a command line, it works well. But when I try to put the
    > script into the Web server (IIS in Windows 2000) and run from a web browser,
    > it works with my local machine only. I have the following error when I try
    > to access any remote server:
    >
    > CGI Error
    > The specified CGI application misbehaved by not returning a complete set of
    > HTTP headers. The headers it did return are:
    > Can't get number of Eventlog records
    >
    > I think it is a permission issue related to IIS. I have already given local
    > admin's right to the account for running applications in Web and logging on
    > to the web server (ISUR_web01 & IWAN_web01). Also, I changed the account
    > for starting up the Web server to a domain admin's account from a system
    > account. But still I cannot make it work.


    You don't need to be admin to read a remote eventlog. The account the
    script runs with only needs SeNetworkLogon privs on the machine it
    should read the eventlog from (at least for the system and application
    eventlog; the security eventlog is another thing). This account has to
    be a domain account.

    I assume the script is *not* running under the user you think it is.
    Perhaps printing out the environment variable USERNAME from the script
    will make this clearer (I guess this will be one of the local accounts
    I???_web01 that have no right whatsoever on the target machines).

    Anyway, this is not a Perl question. I would recommend joining a IIS
    group.

    [snipped code]

    Thomas
     
    Thomas Kratz, Sep 29, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Y2pr?=
    Replies:
    4
    Views:
    6,339
    nosperantos
    Nov 1, 2006
  2. kj7ny
    Replies:
    3
    Views:
    1,008
    fynali
    Jul 10, 2007
  3. JimN

    EventLog access through ASP.Net app

    JimN, Nov 25, 2003, in forum: ASP .Net Security
    Replies:
    2
    Views:
    261
    Juri Zenkevitch
    Nov 26, 2003
  4. Joe
    Replies:
    1
    Views:
    127
    Thomas Kratz
    Sep 29, 2003
  5. Replies:
    6
    Views:
    189
    Matt Garrish
    Jan 26, 2006
Loading...

Share This Page