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

In reply to Re: How to enumerate universal groups in Windows by MaxKlokan
in thread How to enumerate universal groups in Windows by MaxKlokan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.