I have been working with Active Directory today. I am writing some VBScript code that will automatically login a user to our Learning Management System using their Windows login managed by Active Directory. IÂ needed to find all of the groups that a user belongs to. The LMS uses these groups to make course assignments. I found some excellent code examples from Richard Mueller. The samples help you see that ADSI (the library used to access Active Directory and other things) uses two different methods to get the user’s primary group and other groups.
I ran into one problem when getting the list of groups with VBScript. The memberof function usually returns a collection. However, this collection will be empty if ther user does not belong to any groups. In VbScript, you need to use the IsNull() function to see if a collection is empty. All of the ADSI examples that I found on the web used IsEmpty() – a function that will work fine in VB but will not work correctly in VBScript.