Windows 获取广告组中所有用户的SAMAccountName

Windows 获取广告组中所有用户的SAMAccountName,windows,vbscript,active-directory,ldap,Windows,Vbscript,Active Directory,Ldap,我正在寻找一个vbscript,它将检索Active Directory组中所有成员的SAMAccountName 谢谢。这是您正在寻找的脚本: ' 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

我正在寻找一个vbscript,它将检索Active Directory组中所有成员的SAMAccountName


谢谢。

这是您正在寻找的脚本:

'  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