Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: (5) ADSI: Getting a full list of users from a w2k domain

by cacharbe (Curate)
on Sep 11, 2002 at 13:05 UTC ( #196931=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Re: Re: ADSI: Getting a full list of users from a w2k domain
in thread ADSI: Getting a full list of users from a w2k domain

Well, when you execute a command object, you get back a recordset object. Why not prep the RS object ahead of time, and use the command and connection objects after your leg work is done, like so:

use Win32::OLE 'in'; my $ADO = Win32::OLE->new("ADODB.Connection"); $ADO->{Provider} = "ADsDSOObject"; $ADO->Open("ADSI Provider"); my $ADOCmd=Win32::OLE->new("ADODB.Command"); $ADOCmd->{ActiveConnection}=$ADO;#new $ADOCmd->{CommandText}="<$ADSPath>;(objectClass=User);samAccountNam +e,HomeDirectory;SubTree"; my $ADOrs = Win32::OLE->new("ADODB.RecordSet"); $ADOrs->PageSize->{Value}=10000; $ADOrs->Open({Source=>$ADOCmd, ActiveConnection=>$ADO,}) until ($ADOrs->EOF){ my $homeDir=lc($ADOrs->Fields(1)->{Value}); if ($homeDir=~/^\\\\mf/){ my $account=lc($ADOrs->Fields(0)->{Value}); print OUT "$account\t$homeDir\n"; } $ADOrs->MoveNext; } $ADOrs->Close; $ADO->Close; print "Wrote Accounts\n";
My thought is that in VB, you are lucky enough to be able to set the PageSize Property ahead of time, and on execution, the properties are applied when the object is returned. I've come to this (perhaps erroneous) conclusion because if you create the command object and then enumerate through the Command Properties before execution, you get back an empty set.

C-.

---
Flex the Geek


Comment on Re: (5) ADSI: Getting a full list of users from a w2k domain
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://196931]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-07-11 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (220 votes), past polls