Hi I am new to this forum so if I make a mistake in protocol let me know.
OK I have been asked to convert my existing ASP application to make users authenticate with our LDAP servers before starting the application. I have Google'd LDAP and ASP until my eyes hurt, looking for the correct procedure to do a user lookup from ASP.
The platforms are Server:win2000/20003, clients:win2K and winXP
I am hoping to eventually put a standard type login form up on the web site and validate from that.
To get started I thoguht I would grab a script that just browsed the LDAP tree just to test that the connection would work. It didn't I got the results below :(
I have coded a basic file to begin the process but am stuck on a particular line which brings back the error '80072020 which seems to be saying something wrong with the formatting. Here is the script its falling over on line 13.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
</head>
<body>
<%
strUsername = request.queryString("user")
strUserName = Right(strUserName, Len(strUserName) - InStrRev(strUserName, "\"))
Response.Write("Username="&strUserName)
** Failing Line
Set objDomain = GetObject ("LDAP://stockcoll.ac.uk/dc=stockcoll,dc=ac,dc=uk,OU=Staff,OU=Technology Services/")
****
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 memberof FROM 'LDAP://"+objADsPath+"' where sAMAccountname='"+strUsername+"'"
Set rs = Com.Execute
membership=rs("memberof")
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
For each group in membership
newgroup=split(group,"=")
response.write left(newgroup(1), len(newgroup(1))-3)&"<br>"
Next
%>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>
Do I need to Bind to the LDAP database as well, I got to thinking there must be some security involved somewhere.
I have seen some solutions using ASP.NET so I am not bothered whether I use that or not.
Cheers
Kev