Listing sAMAccountName when listing Group Membership



I have used the following script which can be found here -
- for listing all the members of a group:

On Error Resume Next

Set objGroup = GetObject _

arrMemberOf = objGroup.GetEx("member")

WScript.Echo "Members:"
For Each strMember in arrMemberOf
WScript.echo strMember

This works well but I need to display the sAMAccountName for the members of
the group but this isn't available within the group information.

Any ideas? If this isn't the best way (LDAP) and I should be using ADSI
could someone please provide me with a sample script?


Joe Richards [MVP]

You have two options.

1. Attribute Scoped Query will return the sAMAccountName but you can't do it
from ADSI Scripts, you would need to write an LDAP or ADSI C/C++ program.

2. Return the DNs and then lookup each DN individually and return the

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question