Problem with AD LDAP Ranges

Posted on 2006-05-23
Last Modified: 2010-04-07
from vb, this ldap query works for getting all the records:

<LDAP://>;(&(objectCategory=Group)(cn=Group1));distinguishedname,name,member;subtree ........
however, if I try to insert a range into this query the recordset comes back with nothing:

'this does NOT work and there are a few hundred members

Why doesn't that 2nd query work above?  Am I missing something with the RecordSet?  Does anyone have some example vb code that they have used with ldap ranges that I could compare?

I have read a very similar question from Pber posted here:

and have looked at these links already:;en-us;814925
Question by:249Central
    LVL 14

    Accepted Solution

    Your code looks correct, at least the bit that you have posted so far.  When you say the "recordset comes back with nothing", I suspect you're not using the correct field name.

    When you search for "member;range=0-9", that complete string is the field name you need to view in the Recordset.  Ex:

    Set objCon = CreateObject("ADODB.Connection")
    objCon.Open "Provider=ADsDSOObject;"
    Set objCmd = CreateObject("ADODB.Command")
    Set objCmd.ActiveConnection = objCon

    objCmd.CommandText = "<LDAP://>;(&(objectCategory=Group)(cn=Group1));distinguishedname,name,member;range=0-9;subtree"

    Set objRS = objCmd.Execute

    Do While (Not objRS.EOF)
      WScript.Echo objRS("distinguishedname")
      WScript.Echo objRS("name")
      WScript.Echo Join(objRS("member;range=0-9"), vbCrLf)

    Author Comment

    Thanks.  That was exactly what it was.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    729 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

    24 Experts available now in Live!

    Get 1:1 Help Now