ASP Code for Active Directory Authentication

By omasp ·

Someone pls help me with following ASP login page issue, I been trying for last 4-5 weeks but no luck; I don't have much knowledge on ASP.

Currently I am working on ASP login page which
allows user to enter their domain Username / password and once submitted it will authenticate against Active Directory Services and once authenticated it will redirect user to intranet site.

AD Server: Server1
Domain name: mydomain.local

All users are located under root USERS container and don't have any OU.

With Following ASP code,have hardCoded user
credential for testing,

<title>Untitled Document</title>

userName = "asptest"

password = "test1234"

Dim ldapServer, dso, lobjUser, password
Dim server

On Error resume next

' Construct the FQDN
ldapServer = "ldap://Server1:389/DC=mydomain,DC=local"

ldapServer = replace(ldapServer, "#username#", userName)

' Connect to the LDAP Directory

Set dso = GetObject("LDAP:")
userName = Mid(ldapserver, InStr(8, ldapserver, "/") + 1)

'Validate the User Name and Password
Set lobjUser = dso.OpenDSObject(ldapserver, userName, password, ADS_SECURE_AUTHENTICATION)

Response.Write "user: " + userName + " <br/> password: " + password

If Err.number <> 0 Then
Response.Write "<br/><font color=red><STRONG>Authentication Failed!</STRONG></font>"
Set lobjUser = nothing
Set dso = nothing
Response.Write "<br/><font color=green><STRONG>Successfully Authenticated!</STRONG></font>"
end if


Thank you,

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums