cmarti
(Hey THIS is FUN)
2002-11-13 04:54 PM
Global or Local Group

I stole (oops..I mean found..) some code out here that enumerates the groups in a domain and taylored it to meet my needs, I only have one problem now. How can I tell if these groups are global or local? Here's a copy of the script..
code:
 
BREAK ON
$DOMAIN = GetObject("WinNT://MYDOMAIN")
$DOMAIN.FILTER = "group",""
FOR EACH $GROUP in $DOMAIN
? $GROUP.NAME
NEXT

Also, is there some downloadable reference that tells me what properties I can use under $domain.??

Thx..


cmarti
(Hey THIS is FUN)
2002-11-13 05:15 PM
Re: Global or Local Group

Thanks for the post, but I guess I should've mentioned that I'm a newbie to vb scripting and don't understand his code fully. Do I need the whole UDF to tell if the group I'm querying is a local or global group? What I'm looking for is..

code:
BREAK ON
$DOMAIN = GetObject("WinNT://CORP")
$DOMAIN.FILTER = "group",""
FOR EACH $GROUP in $DOMAIN
IF THIS GROUP IS A LOCAL GROUP
? $GROUP.NAME
ELSE
ENDIF
NEXT

Thanks for the post..


Howard Bullock
(KiX Supporter)
2002-11-13 05:22 PM
Re: Global or Local Group

The code below is part of the GetGroups UDF in the UDF Library.

This set an array of the names of the types of groups. They are positioned in the array such that the index represents the grouptype value. (You will see this later)
code:
   Dim $Type[8]
$Type[2] = "GLOBAL_GROUP"
$Type[4] = "LOCAL_GROUP"
$Type[8] = "UNIVERSAL_GROUP"

This code gets the name and grouptype values using COM. The grouptype value is used as the index while referencing the $Type array. This will set the group type TEXT from above into your $GroupType variable.

code:
$GroupName = $group.Name
$GroupType = $Type[$group.groupType]

Does this help or do I need to explain further?

[ 13. November 2002, 18:08: Message edited by: Howard Bullock ]


cmarti
(Hey THIS is FUN)
2002-11-13 06:09 PM
Re: Global or Local Group

OK...I get it now... [Big Grin] Thank you..

One question though. How do you know that GroupType is a property of group? Is there a resource somewhere that references that?


Howard Bullock
(KiX Supporter)
2002-11-13 06:16 PM
Re: Global or Local Group

A good place to start is the ADSI help file which can be downloaded from Microsoft's site.

The next step is to run my EnumObjProps.kix against the object to enumerate the properties. You will find it at: http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=13;t=000139#000003

Note that the properties and their names vary when you use the WinNT:// or LDAP:// ADSI providers.


cmarti
(Hey THIS is FUN)
2002-11-13 06:27 PM
Re: Global or Local Group

Dude...you're good!!! This is just what I needed... Thanks for your help!! [Big Grin]

L8tr...