获取AD组中所有用户的SAMAccountNames

时间:2011-06-20 22:22:33

标签: windows vbscript active-directory ldap

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

感谢。

1 个答案:

答案 0 :(得分:1)

以下是您要查找的脚本:

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