VBScript program demonstrating the use of an efficient IsMember function to test for group membership
for a single user or computer, using the "tokenGroups" attribute. The function reveals
membership in nested groups and the "Primary Group". The IsMember function uses a
dictionary object, so that group memberships only have to be enumerated once, no matter how many
times the function is called.
This program uses the LDAP provider to bind to the user or computer object in Active Directory.
The "tokenGroups" attribute does not reveal cross-domain groups. If you have more than
one domain, this function will not reveal membership in groups that are not in the same domain as
the user or computer.
This program should work on any 32-bit Windows client that can log onto the domain. Windows NT and
Windows 98/95 clients should have DSClient installed. If DSClient is not installed, WSH
and ADSI should be installed.
Typically, this IsMember function would be used in a logon script to map drives to network shares
according to user group membership. It can also be used to map local ports to shared printers
according to computer group membership. However, it can't be used to test both user and computer
group membership in the same program.
IsMember4.txt <<-- Click here to view or download the program
A PowerShell
script that performs the same function is linked below.
PSIsMember4.txt <<-- Click here to view or download the program