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

I'm writing a perl script that takes an array of uids, runs Win32::NetAdmin::LocalGroupIsMember to see if that group is a member of a set of groups, then appends that uid to a file for use in another application.

My problem is that there are over 60 groups that need to be checked, and putting the name of each group into a perl script sounds like a waste of time (I'm lazy). Is there a quick way to get the entire list of groups on a server (local groups)?

Once I get them, I can parse them for our group naming scheme, and run the script to get the uid, check each group to see if the uid is member, then, if positive, add that uid to a list, array, or whatever

I appreciate the help. I checked perldoc for anything of use in Win32::NetAdmin, but didn't see anything I could use. Everything is centered around someone knowing the group name to check already.

JJ (jjhorner)

Replies are listed 'Best First'.
Re: Win32 module and listing groups
by paulbort (Hermit) on May 22, 2000 at 22:46 UTC
    Hopefully I won't get fragged to badly for suggesting a non-PERL answer, but if you're running NT, `net localgroups` and `net group` return lists of groups. Use both at a command prompt to see what the results look like, and get ready to parse the results.

      You won't get fragged from me. I ended up using a non-perl way to get the local group list, then slurping into an array for the work. TIMTOWTDI. JJ

Re: Win32 module and listing groups
by jjhorner (Hermit) on May 22, 2000 at 21:14 UTC

    I have my possible code, but I would like the @group_list to be automatically generated, and the @uid_list will be generated from a flat text file (I think, it isn't defined by customer yet).

    use strict; use Win32::NetAdmin qw(LocalGroupIsMember LocalGroupAddUsers); my $server = "Server"; my $newserver = "NewServer"; # this part is stumping me, so I'll just use an array for now my @group_list = qw(group1 group2 group3 group4); my @uid_list = qw(uid1 uid2 uid3 uid4); foreach $uid (@uid_list) { foreach $group (@group_list) { LocalGroupAddUsers($newserver,$group,$uid) if (LocalGroupIsMem +ber($server,$group,$uid)); } }

    J. J. Horner

    Linux, Perl, Apache, Stronghold, Unix

    jhorner@knoxlug.org http://www.knoxlug.org

Re: Win32 module and listing groups
by Maqs (Deacon) on May 22, 2000 at 19:23 UTC
    I'm not sure that my answer will help you cause it's OS dependent and I do not deal with win32, but most *nixes have the group list in /etc/group stored in its own format. May be you'll find something similar in your OS?
    /Maqs.