I don't know if this answers your specific question, but here is how I've
been doing it.  This is a module I made, and it seems to work fine in native
mode on W2k.



#####################################################
##                                                 ##
##         GETCLIENTS.PM v1.2.20031013             ##
##           written by Tim Johnson                ##
##                                                 ##
#####################################################

package GetClients;
use Win32::Lanman;
use Net::Ping;

#USAGE: GetClients::GetMachines([EMAIL PROTECTED],$domain]) || die "Could not get
a list of computers!\n";
sub GetMachines{
        my $dc;
        my @machines;
        if(-e ".\\current_clients.txt"){
                open(INFILE,"current_clients.txt");
                @{$_[0]} = <INFILE>;
                chomp @{$_[0]};
                close INFILE;
                unlink ".\\current_clients.txt";
        }else{
                my $domain = $_[1];
                $domain = Win32::Lanman::NetGetAnyDCName("",$_[1],\$dc) ||
return 0;
        
Win32::Lanman::NetUserEnum("$dc",FILTER_WORKSTATION_TRUST_ACCOUNT|FILTER_SER
VER_TRUST_ACCOUNT,[EMAIL PROTECTED]) || return 0;
                foreach my $machine(sort{$a->{name} cmp $b->{name}}
@machines){
                        push @{$_[0]},$machine->{name};
                }
                chop @{$_[0]};
        }
        return 1;
}

sub Ping{
        my $p = Net::Ping->new('icmp',2);
        return $p->ping($_[0]);
}

sub GetUsers{
        my $dc;
        if(-e ".\\current_clients.txt"){
                open(INFILE,"current_clients.txt");
                @{$_[0]} = <INFILE>;
                chomp @{$_[0]};
                close INFILE;
                unlink ".\\current_clients.txt";
        }else{
                my $domain = $_[1];
                $domain = Win32::Lanman::NetGetAnyDCName("",$_[1],\$dc) ||
return 0;
        
Win32::Lanman::NetUserEnum("$dc",FILTER_NORMAL_ACCOUNT,$_[0]) || return 0;
        }
        return 1;
}

1

##############################################################

-----Original Message-----
From: Stefan Olsson [mailto:[EMAIL PROTECTED]
Sent: Monday, October 20, 2003 8:36 AM
To: [EMAIL PROTECTED]
Subject: foreach my $computer ($domain)


Hello,

I would like to do an inventory on all pc's in the domain (Active 
Directory). It is just that I have problem to actually retrieve the data 
when doing this:
my $Data = Win32::OLE->GetObject("WinNT://$LocalDomain") or die "Unable 
connect to domain";
-When using Data::Dumper on $Data this is the result:
$VAR1 = bless( {}, 'Win32::OLE' );
-All I want to do is to enumerate the computers in the domain and save them 
in @computers to then do an inventory on each of them. Can someone help me 
on this?

---<script begins here>--------------
#!/usr/bin/env perl
use strict;
use warnings;
use Win32::OLE;
use Data::Dumper;
my $LocalDomain="NTDOMAIN";
my $Data= Win32::OLE->GetObject("WinNT://$LocalDomain") or die "Unable 
connect to domain";

print Dumper($Data);
---<script begins here>--------------
above results in a single line:
$VAR1 = bless( {}, 'Win32::OLE' );

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
http://join.msn.com/?page=features/virus

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to