Classic ASP to Query Active Directory Contacts

Posted on 2014-08-28
Last Modified: 2014-10-01
I have a classic ASP page that I use as a phonebook which queries against Active Directory.

I would like to add another function where it can also query Active Directory for contacts. I have over 100 fax machines that I want users to be able to look up. Our Active Directory Admin create a Contact for each one, and in the last name field called it FAX.

Here is the Query String I'm using to return users in AD and it works fine.

objCom.CommandText ="select name,telephonenumber,mobile,facsimileTelephoneNumber,pager,mail,l,physicalDeliveryOfficeName,company,title,department,sAMAccountName,sn,userAccountControl,msexchhidefromaddresslists FROM 'GC://"+objADsPath+"' where name = '*" & usrname & "*' ORDER BY name "'"
I'm assuming a new query string for Contacts should be just as simple but I can not find any reference material to know what object names to be using.
Question by:guildernet
    LVL 25

    Expert Comment

    by:Shaun Kline
    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    I don't have a way to test this right now but this EE question looks to be on target for what you want to do
    LVL 32

    Accepted Solution

    i believe you want:

    objCom.CommandText ="select fax FROM 'GC://" & objADsPath & "' where (objectCategory=computer)"

    Open in new window

    note I changed

    + objADsPath +


     & objADsPath &

    I'm assuming you're using server side vbscript (which is the default language for classic asp). If you're using server side javascript, then continue with the format you were using

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B. provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    745 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

    15 Experts available now in Live!

    Get 1:1 Help Now