Listing sAMAccountName when listing Group Membership

Pete

Distinguished
Oct 21, 2001
975
0
18,980
Archived from groups: microsoft.public.win2000.active_directory (More info?)

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.
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.active_directory (More info?)

Pete,

You might just get a better reply in the ADSI general news group. Those
guys in there can answer this quickly.

--
Cary W. Shultz
Roanoke, VA 24012
Microsoft Active Directory MVP

http://www.activedirectory-win2000.com
http://www.grouppolicy-win2000.com



"Pete" <Pete@discussions.microsoft.com> wrote in message
news:147DAF0B-9D7B-4894-B365-F938E445BEEE@microsoft.com...
>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.
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.active_directory (More info?)

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.




--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net


Pete wrote:
> 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.