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

Posted on 2006-04-12
Last Modified: 2012-08-13
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
Question by:Ponthecomputer
    LVL 142

    Accepted Solution

    dim samvariable
    samvariable = "johnD"

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

    LVL 1

    Author Comment

    Thanks angelIII

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    withoutTen challenge 14 69
    canBalance challenge 34 58
    linearIn  challenge 23 55
    pairs challenge 5 33
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    A short article about problems I had with the new location API and permissions in Marshmallow
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now