On Error Resume Next
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") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("E:\USERS.xls")
objExcel.Visible = False
i = 2
Do Until objExcel.Cells(i, 1).Value = ""
strName = objExcel.Cells(i,1)
strd = objExcel.Cells(i,2).Value
objCommand.CommandText = _
"SELECT * FROM 'LDAP://dc=windows,dc=microsoft,dc=com' WHERE objectCategory='computer' " & _
"AND Name='" & strName & "'"
Set objRecordSet = objCommand.Execute
' Wscript.Echo objRecordSet.Fields("ADsPath").Value
Set objComputer=GetObject(objRecordSet.Fields("ADsPath").Value)
' Wscript.Echo objComputer.Description
objComputer.Put "description", strd
objComputer.SetInfo
' Wscript.Echo objComputer.Description
i = i + 1
objRecordset.Close
Loop
objConnection.Close
objWorkbook.Close
Set objExcel = Nothing
Bookmark this post:
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ![]() |
0 评论:
发表评论