Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Problem with searh ADO in Active directory on Windows 2000 server

Reply
 
Old 08-10-2009   #1 (permalink)
Francois


 
 

Problem with searh ADO in Active directory on Windows 2000 server

Hi everybody,

Why doesn't this code work ? This code searches users in OU
and prints the sAMAccounteName of users who respect criteria.

'''--------------------------------------------
ldap_adress = "LDAP://OU=comptes, OU=MesUtilisateurs,
DC=yourcenar, DC=lyc"

Set objConnection = Wscript.createObject("ADODB.Connection")
Call objConnection.open ("Provider=ADsDSOObject;")
Set objCommand = Wscript.createObject("ADODB.Command")
objCommand.activeConnection = objConnection
objCommand.commandText = _
"<" & ldap_adress & ">;" & _
"(ObjectCategory=user);" & _
"samaccountname,description;" & _
"subtree"
Set objRecord = objCommand.execute
objRecord.moveFirst

Wscript.echo objRecord.RecordCount 'Give 644 records

Do
'objRecord.find("samaccountname LIKE 's*'")'<----OK!
objRecord.find("description LIKE 'p*'") '<----BOUM!!!
If objRecord.absolutePosition > 0 Then
Wscript.echo objRecord.fields("samaccountname").Value
objRecord.moveNext
End If
Loop While objRecord.absolutePosition > 0
'''--------------------------------------------

With the criterion about "samaccountname", there is no
problem, but why doesn't the equivalent criterion about
"description" work and how can I solve my problem ?

Thank you for your help.


--
François Lafont

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Access Active directory with sql server in powershell PowerShell
Virtualise Windows 2008 Server Active Directory Virtual Server
Windows Server 2003 Ent Edition Active Directory .NET General
Active Directory Connection - Exchange / Server 2003 Vista General
Group Policy for Vista in Windows 2000 Active Directory Domain Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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