ASP and LDAP

_chuma_
_chuma_ used Ask the Experts™
on
Hi experts!
I have a big problem . . .
The whole day I'am traying to connect my asp page to the LDAP server - windows server 2003 , but finaly I realise that the problem is in security settings on IIS 6.
I have administrator rights on domain.
asp pages are on the defoult web sites on my web server
the web server is publishet by the ISA server
plase post any idea

here is a code posted all over the internet that should work - but it's still unuseble for me
in every site i consider that this is a security problem

<%@ Language=VBScript %>
<%
Option Explicit
Dim con,rs,Com,objADsPath,objDomain
%>
<html>
<head>
</head>
<body bgcolor="#CCCCCC">
<%
Set objDomain = GetObject ("GC://RootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
Set objDomain = Nothing
Set con = Server.CreateObject("ADODB.Connection")
con.provider ="ADsDSOObject"
con.open "Active Directory Provider"
Set Com = CreateObject("ADODB.Command")
Set Com.ActiveConnection = con
Com.CommandText ="select department from 'GC://"+objADsPath+"' WHERE department ='*'"
Set rs = Com.Execute

Do While Not rs.EOF Or rs.BOF

Response.Write rs("department") & "<BR>"

rs.MoveNext
Loop
rs.Close

con.Close
Set rs = Nothing
Set con = Nothing
%>
</body>
</html>


best regards Marko
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2005
Commented:
this is a page that i have used to get some basic info.  2003 is pickier than 2000 when doing the queries.  you have to give it credentials that have access to it.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
strUser = "domain\user"
strPassword = "pwd"

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.com' WHERE sn = 'lastname' ORDER by name " 
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
%>

Author

Commented:
Thanks WMIF
Should  DefaultAppPool work under Network Service, Local Service or user account
Witch type of authentication should be set in Default Site?

Author

Commented:
If I set Basic Authentication and logon with DomainAdmin user name I can't open that page
Top Expert 2005

Commented:
at the very top of that code, you need to supply a username and password.  are you doing that?

Author

Commented:
It works!!!
Thanks a lot~~

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial