Domino LDAP Login using ASP - Working Example

I am not a expert in ASP programming but I thought I would take a shot at it and here is what I came up with. Not pretty but it works.

This code is designed to preform a domino ldap lookup and can also be used for authenication.

You will need:

IP works -installation required

  1. http://www.nsoftware.com/default.aspx

  2. Click on Platforms / IDEs → ASP

  3. Select IP*Works!V6 ASP Edition

  4. Trial version will work.

Here is the ASP code:

LDAP Server:
Query:
Pass:

<%

If Request(“REQUEST_METHOD”) = “POST” Then

Dim ldap

Set ldap = Server.CreateObject(“IPWorksASP6.LDAP”)

ldap.ServerName = Request.Form(“server”) 'LDAP Server Name from Request form

ldap.SearchSizeLimit = 100

'at most 100 results

password = Request.Form(“myPassword”)

'retrieving password from request form

username = Request.Form(“query”)

'retrieving username from request form

if ( password = “” ) then

password = “nopassword”

end if

if ( username = “” ) then

username = “no user”

end if

ldap.dn = username

'User name used for Ldap session

ldap.password = password

'password used for Ldap session

ldap.bind

'establishing a session with ldap.

’ if result code is 0 and description is OK then you have a successful login. If result code is 49 and description

’ is "Invalid Credentials, then you will be bounded as anonymous

if ldap.NextResult = 0 then

’ if result code is 0 and description is ok = sucessful login

if ldap.ResultDescription = “[ok]” then

Response.Write(“it worked”)

’ set the required attributes

ldap.AttrCount = 1

ldap.AttrType(0) = “mail”

'email for addresses etc…

ldap.Search “cn=” & Request.Form(“query”)

While ldap.NextResult = 1

'1 is a search result

Response.Write "
Found Name: " & ldap.ResultDN & Chr(13) & Chr(10)

Response.Write "
Found Email: " & ldap.AttrValue(0) & Chr(13) & Chr(10)

Wend

else

Response.Write(“Not Authorized”)

end if

end if

’ Response.Write(“
” & ldap.ResultCode)

’ use the above statement to see result code

Response.Write “”

End If

%>