简体   繁体   中英

Get SAMAccountNames for all users in AD group

I'm looking for a vbscript that will retrieve the SAMAccountNames for all members in a Active Directory Group.

Thanks.

Here is the script you are looking for :

'  Begining from a given group
Dim strGrp
strGrp = "cn=g1,ou=ou,dc=societe,dc=fr"
Set objGroup = GetObject ("LDAP://"& strGrp)
objGroup.getInfo

arrMemberOf = objGroup.GetEx("member")

' Loop = For Each .... Next 
' WScript.Echo "Members of Group "
For Each strMember in arrMemberOf
   WScript.echo strMember
   Set objUser = GetObject ("LDAP://"& strMember)
   sAMAccountName = objUser.GetEx("sAMAccountName")
   WScript.echo sAMAccountName(0)
Next
Wscript.Quit

Here is a site where you can get help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM