Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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

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

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

My first thought is that the Properties object is actually a collection, so it's interface is set up like so:

vs what you have in the code above.

I'm not familiar with the ADSI interface, but that should hopefully get you on the right track with the Command interface at least.



Update: Did some research:

Although what I wrote about the collection is true, from what I've found, you can only set the PageSize in a RecordSet object, 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"); my $ADOrs = Win32::OLE->new("ADODB.RecordSet"); $ADOrs->PageSize->{Value}=10000;

Flex the Geek

Comment on Re: ADSI: Getting a full list of users from a w2k domain
Select or Download Code
Replies are listed 'Best First'.
Re: Re: ADSI: Getting a full list of users from a w2k domain
by OzzyOsbourne (Chaplain) on Sep 10, 2002 at 18:21 UTC

    thanks for the reply! This flexed my brain a bit, and led me to other avenues, but still didn't work. I still get 1000 lines.

    You know that feeling when you work on one line for days? That's how I feel. Does pounding one's head against something solid prodce better code? If so, I should be a master by now.


    I fiddled with the lines until I got it to work. I'm still not sure if it's the ordering of the commands, the double quotes around Page Size, or some combination thereof. the Full Orphan Script will be posted to the Code catacombs. Thanks to cacharbe for all of his suggestions

    sub get_corp_accts{ # get ADO object, set the provider, open the connection my $ADO = Win32::OLE->new("ADODB.Connection"); $ADO->{Provider} = "ADsDSOObject"; $ADO->Open("ADSI Provider"); # Create the ADO Command my $ADSPath = "LDAP://OU=group,DC=subdomain,DC=domain,DC=com"; my $ADOCmd=Win32::OLE->new("ADODB.Command"); $ADOCmd->{ActiveConnection}=$ADO; $ADOCmd->{CommandText}="<$ADSPath>;(objectClass=User);samAccountNa +me,HomeDirectory;SubTree";#new $ADOCmd->Properties->{"Page Size"}=10000; #Execute the Command my $users=$ADOCmd->Execute; #Extract the Info (AccountName, HomeDirectory) from the returned o +bject until ($users->EOF){ my $homeDir=lc($users->Fields(1)->{Value}); my $account=lc($users->Fields(0)->{Value}); print OUT "$account\t$homeDir\n"; $users->MoveNext; } $users->Close; $ADO->Close; print "Wrote Accounts\n"; }


      I know exactly how you feel.

      Check the settings on you AD Server, as per this and this, and note the caveats and limitations on the latter page regarding max number of entries in a secondary user group, and the MAX size of MaxPageSize.

      Short of it: Looks like you can set MaxPageSize in AD as well, but the MAX MaxPageSize / request is 1000...Looks like you're SOL (another microsoft link here that supports the claim).


      Flex the Geek

        But it can be done in VBScript with almost identical code. The offending line that I can't translate from VBScript is objADOCmd.Properties("Page Size")=10000. So it must be possible. I'm missing something. I have to be.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2015-11-30 03:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (757 votes), past polls