Thanks Steven! That was it. I knew I had the whole routine mixed up
but couldn't get it sorted out properly. I had actually tried querying
the entire domain (over 10,000 PCs) and still only got 2000 back. Now
I'm back on track and see where I got twisted up. I now get 5800+ PC's
returned with the changes you recommended in this modified version that
checks a portion of our domain. Thanks again.
use strict;
use Win32::OLE 'in';
use Win32::OLE::Const 'Active DS Type Library';
$Win32::OLE::Warn = 3;
my $domain = "DC=us002,DC=siemens,DC=net";
my $ou = "OU=Cat-Computers,OU=CAT,".$domain;
my ($result, $name, $ver, $cnt);
my %targets = ();
my $path = "LDAP://".$ou;
my $filter = "(objectClass=Computer)";
my $columns = "Name,operatingSystem";
my $string = "<$path>;$filter;$columns;subtree";
my $Com = Win32::OLE->new("ADODB.Command");
my $Conn = Win32::OLE->new("ADODB.Connection");
$Conn->{'Provider'} = "ADsDSOObject";
$Conn->{Open};
$Com->{ActiveConnection} = $Conn;
$Com->{CommandText} = $string;
$Com->{Properties}->{"Page Size"} = 99;
my $RS = $Com->Execute();#you actually are executing the connection
object..
until ($RS->EOF){
$name = $RS->Fields(0)->{Value};
$ver = $RS->Fields(1)->{Value};
$targets{$name} = $ver;
$cnt++;
$RS->MoveNext;
}
$RS->Close;
print "Found $cnt objects in $ou\n";
Regards,
Glenn
-----Original Message-----
From: Steven Manross [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 21, 2007 3:52 PM
To: Deans, Glenn (SBS US); [email protected]
Subject: RE: Active Directory query limited to 2000 objects?
Are your computers all in that base OU? Or are they nested? That's a
longshot (because the odds of returning exactly 2000 records and this be
the problem are somehwat astronomical).. But, it's worth a shot.
However, if they are nested, try "subtree" instead of "OneLevel" in your
search filter.
The "Page Size" property is the correct value to be manipulating..
$objADOcmd->{Properties}->{"Page Size"} = 100;
As well, try the:
$objADOcmd->{Properties}->{"Sort On"} = "CN";
Just to see that the properties are correctly being set correctly (and
read by the objects.. My guess is that this won't change the order of
your resultsets based on my next comment).
I haven't used your method of executing the connection before..
I do this (error checking omitted):
my $string = "<$path>;$filter;$columns;subtree";
my $Com = Win32::OLE->new("ADODB.Command");
my $Conn = Win32::OLE->new("ADODB.Connection");
$Conn->{'Provider'} = "ADsDSOObject";
$Conn->{Open};
$Com->{ActiveConnection} = $Conn;
$Com->{CommandText} = $string; #you don't do this.. And this leads up
to the the next comment
$Com->{Properties}->{"Page Size"} = 99;
my $RS = $Com->Execute();#you actually are executing the connection
object..
# Where I execute the Command object (which
has the Page Size property set).
#and may be the problem
Cheers!
Steven
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Deans, Glenn (SBS US)
Sent: Monday, February 19, 2007 11:39 AM
To: [email protected]
Subject: RE: Active Directory query limited to 2000 objects?
Thanks Shawn. I thought it was a limit of 1000 as well, from what I saw
@MSDN. But I'm still only getting 2000 objects with that line added in
place of the 'Size Limit' line.
Regards,
Glenn
-----Original Message-----
From: Shawn Boyle [mailto:[EMAIL PROTECTED]
Sent: Monday, February 19, 2007 1:11 PM
To: Deans, Glenn (SBS US); [email protected]
Subject: RE: Active Directory query limited to 2000 objects?
You need to specify a page size for your command object. If you don't
you only get back the first set of objects [I thought it was the first
1000, but maybe that changed somewhere] and that's it.
Add:
$objADOcmd->Properties->{'Page Size'} = 1000;
And you should be good. Though I'm not familiar with the Size Limit
property so I don't know if that will cap the result set -- you might
want to lose it.
HTH,
-Shawn
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Deans, Glenn (SBS US)
Sent: Monday, February 19, 2007 10:36 AM
To: [email protected]
Subject: Active Directory query limited to 2000 objects?
Hi all! I'm running into a problem when I query our domain. I'm trying
to enumerate a specific OU for the computers and I can only get 2000
objects back. I can't seem to find a property for this or a way to
change the limit. The 'Size Limit' property in line 21 has no effect and
I can't find a way to set 'MaxRecords', but I think the default for that
is unlimited. It's not a show stopper for this script, but it will be in
the future.
Am I missing something?
_______________________________________________
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