M
Mariusz Gadula
Hi,
Using examples from Internet I am writing library to manage IIS
metabase in Perl (ActiveState). I have problem with procedure that
will dump metabase settings. The problem is with enumeration of
properties. In line where I should get properties names I get nothing.
Part of the code bellow:
########################################################################
package IIS;
use strict;
use warnings;
use Win32;
use Win32::OLE qw(in with);
use Data:ump qw(dump);
#Win32::OLE->Option(Warn => 0);
my $VERSION=1.0.0.2;
$|=1;
#
# new - create and instance
#
sub new {
my $class = shift;
$class = ref( $class ) || $class;
my $hostname = shift;
$hostname = defined $hostname ? $hostname : 'localhost';
my $self = {};
$self->{ 'hostname' } = $hostname;
$self->{ 'W3SVC'} = Win32::OLE->GetObject("IIS://$hostname/W3SVC");
$self->{ 'error_string' } = 'success';
bless( $self, $class );
return $self;
}
#
# get_error_string - retrieve the error string
#
sub get_error_string {
my $self = shift;
return $self->{ 'error_string' };
}
#
# IIS subs
#
[...]
#
# Not ready!
#
sub dump_www {
my $self = shift;
my $vdirObj = $self->{ 'W3SVC'};
my %DUMP = ();
if (defined $vdirObj) {
&show_object($vdirObj,0);
$self->{ 'error_string' } = $^E if (Win32::OLE->LastError());
} else {
$self->{ 'error_string' } = $^E;
return 0;
}
# return %;
}
sub show_object {
my $hash = shift (@_);
my $count = shift (@_);
my $ptab = '';
for(my $i=0; $i<$count; $i++) { $ptab .= "\t"; }
print "$ptab",$hash->{Name},"\n";
my %PROPERTIES = %$hash; # <- HERE
map {print "\t$ptab",$_,"\n";} sort keys %PROPERTIES;
print "\n";
for my $object (in $hash) {
&show_object($object,$count + 1);
}
}
sub destroy {
Win32::OLE->FreeUnusedLibraries();
Win32::OLE->Uninitialize();
1;
};
1;
###################################################################
The result is :
----------------
W3SVC
1
Filters
IIsCertMapper
ROOT
AppPools
DefaultAppPool
Filters
Compression
deflate
gzip
Parameters
Info
Templates
Public Web Site
Root
Secure Web Site
Root
Using examples from Internet I am writing library to manage IIS
metabase in Perl (ActiveState). I have problem with procedure that
will dump metabase settings. The problem is with enumeration of
properties. In line where I should get properties names I get nothing.
Part of the code bellow:
########################################################################
package IIS;
use strict;
use warnings;
use Win32;
use Win32::OLE qw(in with);
use Data:ump qw(dump);
#Win32::OLE->Option(Warn => 0);
my $VERSION=1.0.0.2;
$|=1;
#
# new - create and instance
#
sub new {
my $class = shift;
$class = ref( $class ) || $class;
my $hostname = shift;
$hostname = defined $hostname ? $hostname : 'localhost';
my $self = {};
$self->{ 'hostname' } = $hostname;
$self->{ 'W3SVC'} = Win32::OLE->GetObject("IIS://$hostname/W3SVC");
$self->{ 'error_string' } = 'success';
bless( $self, $class );
return $self;
}
#
# get_error_string - retrieve the error string
#
sub get_error_string {
my $self = shift;
return $self->{ 'error_string' };
}
#
# IIS subs
#
[...]
#
# Not ready!
#
sub dump_www {
my $self = shift;
my $vdirObj = $self->{ 'W3SVC'};
my %DUMP = ();
if (defined $vdirObj) {
&show_object($vdirObj,0);
$self->{ 'error_string' } = $^E if (Win32::OLE->LastError());
} else {
$self->{ 'error_string' } = $^E;
return 0;
}
# return %;
}
sub show_object {
my $hash = shift (@_);
my $count = shift (@_);
my $ptab = '';
for(my $i=0; $i<$count; $i++) { $ptab .= "\t"; }
print "$ptab",$hash->{Name},"\n";
my %PROPERTIES = %$hash; # <- HERE
map {print "\t$ptab",$_,"\n";} sort keys %PROPERTIES;
print "\n";
for my $object (in $hash) {
&show_object($object,$count + 1);
}
}
sub destroy {
Win32::OLE->FreeUnusedLibraries();
Win32::OLE->Uninitialize();
1;
};
1;
###################################################################
The result is :
----------------
W3SVC
1
Filters
IIsCertMapper
ROOT
AppPools
DefaultAppPool
Filters
Compression
deflate
gzip
Parameters
Info
Templates
Public Web Site
Root
Secure Web Site
Root