Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active Directory LDAP query

Status
Not open for further replies.

bslintx

Technical User
Apr 19, 2004
425
US
Hi,

i am trying to lookup "distinct" title's in AD; however, i had no luck. i am using....

Code:
 Set oRs2 = oConn.Execute("SELECT name, title, physicaldeliveryofficename " & _
                          "FROM 'LDAP://" & getUnitPath & getDomain & "' " & _
                          "WHERE department='" & getDepartment & "' AND physicaldeliveryofficename='" & aData(0,i) & "' ORDER BY title")

...which is fine, but it grabs all when i want a distinct list..ie: if returned...

title:
Worker bee
Mgr
Mgr
Worker bee
Operator

i want...
Worker bee
Mgr
Operator
 
Either sql dialect or ldap query, distinct is not supported. Hence, you have to loop through the resultset and extract distinct title attribute. In vb(s), usually use a dictionary object using its dictionary.exists() method to test for the title string. If exists, then reject it as duplication; if not, set up a key value with that title string with arbitrary item value.
 
Thanks for the reply..i didn't post it but i came up with a conditional loop to what you were going to...i was simply hoping to return a smaller recordset with distinct in the query...thanks for the heads up. i can now stop scouring for the answer

Code:
 For i = iRecFirst To iRecLast
    If i = iRecLast Then
     j = j - 1
    Else
     j = j + 1
    End If
    If NOT isNull(aOffice(0,i)) Then
     If aOffice(0,i) <> aOffice(0,j) Then
       Response.Write aOffice(0,i) & "<br>"
     End If
    End If
 Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top