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?

   1. use strict;
   2. use Win32::OLE 'in';
   3. use Win32::OLE::Const 'Active DS Type Library';
   4. $Win32::OLE::Warn = 3;
   5.
   6. my $domain = "DC=us002,DC=siemens,DC=net";
   7. my $ou = "OU=Clients,".$domain;
   8. my ($result, $name, $ver, $cnt);
   9. my %targets = ();
  10. my $ADsPath = "LDAP://".$ou;
  11. my $query =
"(objectClass=Computer);Name,operatingSystem;OneLevel";
  12. my $objADOcn = Win32::OLE->new('ADODB.Connection');
  13. $objADOcn->{Provider} = "ADsDSOObject";
  14. #$objADOcn->Properties->{'User ID'} = $user;
  15. #$objADOcn->Properties->{'Password'} = $passwd;
  16. $objADOcn->Open("ADSI Provider");
  17. die Win32::OLE->LastError() if Win32::OLE->LastError( );
  18.       
  19. my $objADOcmd = Win32::OLE->new('ADODB.Command');
  20. $objADOcmd->{ActiveConnection} = $objADOcn;
  21. $objADOcmd->Properties->{'Size Limit'} = 3000;
  22.     
  23. my $result = $objADOcn->Execute("<$ADsPath>;".$query);
  24. die Win32::OLE->LastError() if Win32::OLE->LastError( );
  25.
  26. until ($result->EOF){
  27.   $name = $result->Fields(0)->{Value};
  28.   $ver = $result->Fields(1)->{Value};
  29.   $targets{$name} = $ver;
  30.   $cnt++;
  31.   $result->MoveNext;
  32. }
  33. $result->Close;
  34. $objADOcn->Close;
  35. print "Found $cnt objects in $ou\n";

Regards,
Glenn
_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to