http://qs321.pair.com?node_id=611468

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

Hello fellow Monks!

Does anybody know how to enumerate Windows Universal Groups in Perl? Win32API::Net and Win32::NetAdmin do not seem to support it.
Is Win32::OLE the only way to go, if at all?

Thanks in Advance,

Max
  • Comment on How to enumerate universal groups in Windows

Replies are listed 'Best First'.
Re: How to enumerate universal groups in Windows
by strat (Canon) on Apr 24, 2007 at 07:30 UTC

    If you go with Win32::OLE, you might find http://rallenhome.com/blog/adcookbook/ interesting... (especially the codes examples for Perl)

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

      That put me on the right track. Thanks!
Re: How to enumerate universal groups in Windows
by NetWallah (Canon) on Apr 23, 2007 at 13:30 UTC
    How about Net::LDAP ?

         "Choose a job you like and you will never have to work a day of your life" - Confucius

Re: How to enumerate universal groups in Windows
by MaxKlokan (Monk) on Apr 26, 2007 at 12:52 UTC
    I found myself a solution based on the examples from the book suggested by strat.
    Here is an example of minimal code for a function that returns the type of group (including universal groups) for a given group, in case anybody is interested.
    #!perl use warnings; use strict; use Win32::OLE; # map group type codes to meaningful names my %groupType = ( -2147483644 => 'Local Security Group', -2147483646 => 'Global Security Group', -2147483640 => 'Universal Security Group', 4 => 'Local Distribution Group', 2 => 'Global Distribution Group', 8 => 'Universal Distribution Group', -2147483643 => 'Builtin Group' ); my $groupname = 'DOMAIN\GROUP'; print $groupname, " => ", GroupType($groupname); sub GroupType { my($domain,$group) = split /\\/,shift; # Set up the ADO connections my $connObj = Win32::OLE->new('ADODB.Connection'); $connObj->{Provider} = "ADsDSOObject"; $connObj->Open; my $commObj = Win32::OLE->new('ADODB.Command'); $commObj->{ActiveConnection} = $connObj; # Grab the default root domain name my $rootDSE = Win32::OLE->GetObject("LDAP://$domain/RootDSE"); my $rootNC = $rootDSE->Get("defaultNamingContext"); # Run ADO query and return the group type my $query = "<LDAP://$domain/$rootNC>;"; $query .= "(&(CN=$group)(objectClass=Group));"; $query .= "cn,groupType;"; $query .= "subtree"; $commObj->{CommandText} = $query; my $resObj = $commObj->Execute($query); die "Could not query $domain: ",$Win32::OLE::LastError,"\n" unless + ref $resObj; return($groupType{$resObj->Fields("groupType")->value}); }
    Max