Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

using ADSI to recurse the group object for all members of a group.

by enigmae (Pilgrim)
on Feb 28, 2002 at 16:16 UTC ( [id://148262]=perlquestion: print w/replies, xml ) Need Help??

enigmae has asked for the wisdom of the Perl Monks concerning the following question:

Greetings,
I am trying to get all the members of a group in Active
Directory. Using ADSI, i can get a group object,
however i don't know how to retrieve a list of all the
members. I know that there is a function in the group
object called members,
HRESULT Members( IADsMembers** ppMembers);
my problem is how do i make a variable of type
IADsMembers in PERL. some sample VB code on how to do
this was on MSDN, here is what it looks like:
Dim grp As IADsGroup Dim memberList As IADsMembers Dim member As IADs Set grp = GetObject("WinNT://Microsoft/Administrators") Set memberList = grp.members For Each member In memberList Debug.Print member.Name & "(" & member.Class & ")" Next

I checked to see if there are any types in the PERL
docs, but i couldn't find any.
If anyone has done this before or could help me figure
it out, it would be greatly appriciated.
TIA,
Lucas krause
  • Comment on using ADSI to recurse the group object for all members of a group.
  • Download Code

Replies are listed 'Best First'.
Re: using ADSI to recurse the group object for all members of a group.
by Kanji (Parson) on Feb 28, 2002 at 17:10 UTC

    I'm not familiar with Dim, but porting sample VB snippets to Perl is usually trivial ... at least enough so that you have a good starting point.

    #!perl # Works on my Win2K box running # Perl 5.6.1 (AS's 630 build); # maybe it'll work for you, too! :-) use strict; use warnings; use Win32; use Win32::OLE 'in'; my $group = sprintf "WinNT://%s/Administrators", shift || Win32::NodeName; my $admin = Win32::OLE->GetObject($group) or die( Win32::OLE->LastError, "\n" ); for my $member ( in $admin->members ) { printf "%s (%s)\n", $member->name, $member->class; }

        --k.

Re: using ADSI to recurse the group object for all members of a group.
by strat (Canon) on Feb 28, 2002 at 16:25 UTC
    Sorry, I can't help you with ADSI because I've never tried working with it. For accessing directory services (eg. AD, OpenLDAP, Siemens DirX, Netscape and even Exchange), I always use Net::LDAP, which contains good documentation.

    Best regards,
    perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"

Re: using ADSI to recurse the group object for all members of a group.
by davis (Vicar) on Feb 28, 2002 at 16:27 UTC
    I don't have the answer to your question ( I do not work with windows boxes), but the O'Reilly Book Perl for System Administration includes a chapter on ADSI which you may find helpful, especially if this is a reasonably long-lived project
    hope that helps
    davis
    Is this going out live?
    No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist
      hello,
      Yeah i have that book, that is how i came upon ADSI.
      However it gives examples using properties, but not
      getting interfaces themselves. thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://148262]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (1)
As of 2024-04-25 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found