Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   VBScript AD Select all users beginning with!!! (http://www.go4expert.com/forums/vbscript-ad-select-users-beginning-t5711/)

covachero 6Aug2007 18:56

VBScript AD Select all users beginning with!!!
 
Hi to all you guys, this is my first thread, well this is my question: Im using an LDAP SQL statement to retireve a user OU, but I want to look the OUs for all users beginning with a letter Example: A%

This is the code I use:

Code:

Set rs = CreateObject("adodb.recordset")
Connstring = "Provider=ADsDSOObject"

strSQL = "SELECT distinguishedName FROM 'LDAP://ou=es,dc=prg-dc,dc=dhl,dc=com' WHERE sAMAccountName = 'jdoe'"
       
rs.Open strSQL, Connstring
    Do Until rs.EOF
WScript.Echo rs("distinguishedName")
Loop
rs.close

strUserDN = LCase(fullpath)
               
Set objUser = GetObject ("LDAP://" & strUserDN)

Thanks a lot...

shabbir 6Aug2007 19:50

Re: VBScript AD Select all users beginning with!!!
 
I am not a LDAP SQL expert but you can refer to the LIKE operator which we have.

Code:

....  WHERE sAMAccountName LIKE 'A%'

covachero 6Aug2007 20:00

Re: VBScript AD Select all users beginning with!!!
 
Thanks for the repply, I though the same but it gives me this error when run it :
Provider: One or more errors occurred during processing of command.

It doesn't give an error number or anything but that

jwshepherd 13Aug2007 11:17

Re: VBScript AD Select all users beginning with!!!
 
Try
Code:

....WHERE sAMAccountName LIKE 'A%'
instead of percentage

covachero 14Aug2007 12:45

Re: VBScript AD Select all users beginning with!!!
 
Quote:

Originally Posted by jwshepherd
Try
Code:

....WHERE sAMAccountName LIKE 'A%'
instead of percentage

Don't understando (Instead of percentage) what I'm suppose to use instead of percentage?

Thank you for your repply.

jwshepherd 14Aug2007 12:50

Re: VBScript AD Select all users beginning with!!!
 
sorry try an asterick instead of a percent sign.*

covachero 14Aug2007 13:36

Re: VBScript AD Select all users beginning with!!!
 
Thanks a lot, with the * works just great.

jwshepherd 14Aug2007 19:01

Re: VBScript AD Select all users beginning with!!!
 
no problem


All times are GMT +5.5. The time now is 03:54.