Using a variable in a SELECT statement when querying LDAP - VBScript

I need to query LDAP using a variable as part of the select statement. This syntax won't work. Is is possible to do this and if so, how can I correct this so that it will work? Thanks!

dim samvariable
samvariable = johnD

"SELECT mail FROM 'LDAP://dc=fabrikam,dc=com' WHERE objectCategory='user' " & _
        "AND sAMAccountName=" & samvariable
LVL 1
PonthecomputerAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
dim samvariable
samvariable = "johnD"

"SELECT mail FROM 'LDAP://dc=fabrikam,dc=com' WHERE objectCategory='user' " & _
        "AND sAMAccountName='" & samvariable & "'"

0
 
PonthecomputerAuthor Commented:
Thanks angelIII
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.