I have the following code to search the domain called mx for the current computer name, I seem to be having problems with the syntax at the line indicated by the * it gives me an error saying "The search filter cannot be recognised" can anyone see what i have done wrong? Also, it seems to be taking an age to exit the DO WHILE LOOP, as soon as it finds one record i want it to exit as it will only ever find one record with a matching name! Right?
Please help!
___________________________________________________________
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
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://dc=MX,dc=int' WHERE objectCategory='computer' and name = '" & strComputer & "'"
Set objRecordSet = objCommand.Execute
*objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
Set objComputer = GetObject("LDAP://" & strDN)
objComputer.Put "Description" , strMAC & "," & strIP & "," & strSTN
objComputer.SetInfo
Please help!
___________________________________________________________
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
objCommand.CommandText = "SELECT distinguishedName FROM 'LDAP://dc=MX,dc=int' WHERE objectCategory='computer' and name = '" & strComputer & "'"
Set objRecordSet = objCommand.Execute
*objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName").Value
objRecordSet.MoveNext
Loop
Set objComputer = GetObject("LDAP://" & strDN)
objComputer.Put "Description" , strMAC & "," & strIP & "," & strSTN
objComputer.SetInfo