Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: List of groups on Win32

by clemburg (Curate)
on Feb 16, 2001 at 17:35 UTC ( #58855=note: print w/replies, xml ) Need Help??


in reply to List of groups on Win32

Get your copy of Win32 Perl Programming by Dave Roth. Pages 80-88 (Group Account Management) list want you want.

Seems that you can retrieve a list of groups by using the Win32::AdminMisc::GetGroups() function.

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com

Replies are listed 'Best First'.
Re: Re: List of groups on Win32
by $code or die (Deacon) on Feb 16, 2001 at 20:38 UTC
    For anyone who's interested, I posted a review on Win32 Perl Scripting: Administrator's Handbook by Dave Roth and its here

    $code or die
    Using perl at
    The Spiders Web
Thanks
by pwhysall (Acolyte) on Feb 16, 2001 at 19:44 UTC
    But I have a problem with AdminMisc - it seemed to install OK, but every time I call my little program:
    #!/usr/bin/perl -w
    
    use Win32::AdminMisc qw(GetDC GetGroups);
    
    my $dc;
    my @groups;
    
    $dc = GetDC();
    
    GetGroups($dc, GROUP_TYPE_ALL, \@groups);
    
    my $item;
    
    foreach $item(@groups) {
      print "$item\n";                                          
    }
    

    I get an error message:

    bash-2.02$ perl dominfo.pl
    "GetDC" is not exported by the Win32::AdminMisc module at dominfo.pl line 3
    "GetGroups" is not exported by the Win32::AdminMisc module at dominfo.pl line 3
    Can't continue after import errors at dominfo.pl line 3
    BEGIN failed--compilation aborted at dominfo.pl line 3.
    bash-2.02$
    

    I'm not up on how perl modules and such work, so I don't know how to fix this :-(

      First off: baku's given you a good fix

      Here's the 'why' ... Perl modules that export symbols usually use the Exporter module internally. Such modules maintain lists of symbols (names of variables and subroutines) they automatically export (@EXPORT) and ones that they may export if asked to (@EXPORT_OK). (exported symbols can be accessed without fully qualifying their names).

      The module you're using doesn't list either of the symbols you're asking it to export (with the qw() construct) in its list of exportable symbols, hence the error.

      Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      Those messages indicate that the module uses Exporter but did not put those functions in @EXPORT_OK to indicate that they could be exported. I would first check the module's documentation to see whether you have the names correct (including documentation) and if you do I would just stop trying to import them and use them directly, or I would add the lines:
      *GetDC = *Win32::AdminMisc::GetDC; *GetGroups = *Win32::AdminMisc::GetGroups;
      to manually import. (Well I would also go into the module, add a patch, and then send a bug report to the author, but that is just me...)
        I'm literally amazed by the response. Mad props to all who took the time to reply.

        Unfortunately (?) I'm currently trapped in Linux (hehe) and so can't test the fixes that people have so very kindly suggested, but you can be sure that I will test them out and let you all know how it goes.

        Once again, many thanks.

        I'm literally amazed by the response. Mad props to all who took the time to reply.

        And now the bad news. I can't test this stuff today - I'm now in the Linux half of my job and Win32 stuff doesn't seem to want to work :-).

        You can be sure, however, that I will be testing out the ideas that have been so kindly offered here on Monday, and I will report back in the hope that my experiences will help someone else.

        Thanks again, everyone.

      Try removing the qw[] block, and using the "qualified" names (like Win32::AdminMisc::GetGroups)... does that help any?

      I'm not up on how perl modules and such work,

      This can also be said for many authors of Win32:: modules. ): You'd think Dave Roth would know better by now, but perhaps it is just "history" for this particular module.

      A simple @EXPORT_OK= qw( list of subs ) would make this module easier to use (and fit the common expectations for a Perl module).

              - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2019-09-18 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (237 votes). Check out past polls.

    Notices?