|
on error resume next
objGroupName=InputBox("Please enter the group name : ")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(objGroupName & ".txt")
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select adspath from 'LDAP://DC=Test,DC=com'Where objectClass='group' and name='" & objGroupName & "'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
GroupPATH = objRecordSet.Fields("adsPath").Value
set objGroup = GetObject(GroupPATH)
If isarray(objGroup.member) = True Then
For Each strUser in objGroup.member
Set objUser = GetObject("LDAP://" & strUser)
objFile.WriteLine objUser.Title
Next
Else
Set objUser = GetObject("LDAP://" & objGroup.member)
objFile.WriteLine objUser.Title
End If
objFile.Close
objRecordSet.MoveNext
Loop
把上面内容保存为.vbs的脚本文件,把其中的DC=Test,DC=com改成你自己的环境。
双击运行,弹出窗口中输入你的组名,然后在该VBS同目录会出现文本,其中为Title的列表。
该文件在任何加域的机器上都可以运行。 |
评分
-
查看全部评分
|