开发者

Get SAMAccountNames for all users in AD group

I'm looking for a vbscript that will retrieve t开发者_高级运维he 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜