Access Right for Perlscript to Read Windows EventLog Remotely

J

Joe

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>";
 
T

Thomas Kratz

Joe said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top