troubleshooting Question

LDAP Query - get OU names with ldap query

Avatar of elchuma
elchuma asked on
ASP
2 Comments1 Solution13065 ViewsLast Modified:
Hi experts!!!
I'am building intranet app based on LDAP database.
With exchange experts help I made page that query LDAP, so I have user names, mail, tel. no. . . .
I need to query LDAP for OU names.
Is it possible?

here is the code posted by WMIF that I used for Intranet app. to get user names.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
strUser = "DOMAIN\user"
strPassword = "pass"

Dim Conn, strRS, RS, strConn
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")

Conn.Provider = "ADsDSOObject"
Conn.Properties("User ID") = strUser
Conn.Properties("Password") = strPassword
Conn.Properties("Encrypt Password") = True
strConn = "Active Directory Provider"
Conn.Open strConn , strUser, strPassword

strRS = "SELECT sn,givenName,memberOf FROM 'LDAP://domain.co.yu' WHERE objectCategory='person'"
RS.Open strRS, Conn,1,1
While RS.EOF = False
memgroups = rs("memberOf")
for each memgroup in memgroups
%>            
     <%=rs.Fields("sn")%> - <%=rs.Fields("givenname")%>&nbsp;<%=memgroup%><br>
<%
next
     RS.MoveNext
Wend
%>

Best Regards,
Marko
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros