Listing sAMAccountName when listing Group Membership

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have used the following script which can be found here -
http://www.microsoft.com/technet/scriptcenter/scripts/ad/groups/adgpvb13.mspx
- for listing all the members of a group:

On Error Resume Next

Set objGroup = GetObject _
("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")

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

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?

Thanks.
 
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
sAMAccountName.
 

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

Back
Top