Advertisement
Advertisement
| 05.01.2008 at 06:50AM PDT, ID: 23368467 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: |
properly working computer version:
Const ADS_SCOPE_SUBTREE = 2
TxtFile = "comps.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(TxtFile)
Do until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
strComputer = strNextLine
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=xxxx,DC=xxxx' Where objectClass='computer'" & _
" and Name = '" & strComputer & "'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Set objComputer = GetObject(objRecordSet.Fields("ADsPath").Value)
objComputer.DeleteObject (0)
objRecordSet.MoveNext
Loop
*******************************************
not working "user version":
Const ADS_SCOPE_SUBTREE = 2
TxtFile = "users.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(TxtFile)
Do until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
strComputer = strNextLine
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=xxxx,DC=xxxx' Where objectClass='user'" & _
" and Name = '" & strComputer & "'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Set objComputer = GetObject(objRecordSet.Fields("ADsPath").Value)
objComputer.DeleteObject (0)
objRecordSet.MoveNext
Loop
Loop
|