本脚本有ygy同志亲情提供
修改下ldap路径及密码即可使用
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.Properties("Page Size") = 200
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT adspath,name FROM 'LDAP://dc=shenma,dc=local' WHERE objectCategory='user' "
Set objRec = objCommand.Execute
if objRec.BOF OR objRec.EOF then
wscript.echo "不存在"
else
FOR i = 1 to objRec.RecordCount
UserPATH = objRec.Fields("adsPath").Value
set obj = GetObject(UserPATH)
obj.setpassword "111111"
obj.setinfo
wscript.echo objRec.Fields("name").Value
objRec.MoveNext
Next
wscript.echo objRec.RecordCount&"个用户成功!"
end if
wscript.echo "不存在"
else
FOR i = 1 to objRec.RecordCount
UserPATH = objRec.Fields("adsPath").Value
set obj = GetObject(UserPATH)
obj.setpassword "111111"
obj.setinfo
wscript.echo objRec.Fields("name").Value
objRec.MoveNext
Next
wscript.echo objRec.RecordCount&"个用户成功!"
end if
转载于:https://blog.51cto.com/54lihui/331643