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

How can I find out what groups (local or global)a user is a member of.. In p135 of Dave Roth Win32Perl Programming '2nd ed' there is an example but you have to retieve every single groupe available first and then feed it to Win32::NetAdmin::GroupIsMember and Win32::NetAdmin::LocalGroupIsMember, which seems of a bit long process just to do this. Is there any better way to do it??
I also have tried example 6.7 from Dave Roths 1st edition- still no Joy – I have been tortured by Perl –Really (in spite of constantly reading about it!!!!!!!)

edited: Thu Jun 27 14:29:46 2002 by jeffa - title amendment

Replies are listed 'Best First'.
Re: User Group membership: a better way?
by Marza (Vicar) on Jun 27, 2002 at 17:25 UTC

    Take a look at Win32API::Net. You have UserGetGroups for globals and UserGetLocalGroups for locals.

    Using your code from your previous post:

    use strict 'vars'; use warnings; use Win32API::Net; use Win32::NetAdmin; my $name = Win32::LoginName(); my $domain = Win32::DomainName(); my $pdc; my @GlobalGroups; Win32::NetAdmin::GetDomainController('',$domain,$pdc); print "Name: $name,\tDomain: $domain,\tPDC: $pdc\n"; Win32API::Net::UserGetGroups($pdc,$name,\@GlobalGroups); foreach ( @GlobalGroups ) { print "Found: $_\n"; }

    This will list out the the id's global group memberships from the domain controller.

      Many Thanks,...but @GlobalGroups does not get populated with anything?not sure why? I think I have tried everything now.

        He answered this in his other post. No need to respond.