Re: LDAP Authentication
From: Mark Schupp (mschupp_at_ielearning.com)
Date: 05/29/03
- Next message: Jim: "Re: LDAP Authentication"
- Previous message: Jason S: "Re: Probable Internet Explorer Problem"
- In reply to: Jim: "LDAP Authentication"
- Next in thread: Jim: "Re: LDAP Authentication"
- Reply: Jim: "Re: LDAP Authentication"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 29 May 2003 08:03:10 -0700
try
Set lobjUser = dso.OpenDSObject(ldapserver, userName, password, 1)
You might also want to check for the specific error meaning that an invalid
login name or password was supplied. Here is what I use:
If Err.Number = 0 Then
AuthenticateUser = 0 'authenticated.
ElseIf Err.Number = -2147023570 Then
'8007052e - LDAP_INVALID_CREDENTIALS - The supplied credential is invalid.
' ERROR_LOGON_FAILURE - Logon failure: unknown user name or bad
password.
AuthenticateUser = 1 'not authenticated
Else
'error occurred
strErrorMsg = Err.Number & ":" & Err.Description
AuthenticateUser=999
End If
-- Mark Schupp -- Head of Development Integrity eLearning Online Learning Solutions Provider mschupp@ielearning.com http://www.ielearning.com 714.637.9480 x17 "Jim" <jmackin@hastings.edu> wrote in message news:O0e%23tDeJDHA.1024@TK2MSFTNGP10.phx.gbl... > I am trying to create an asp page that will authenticate against AD using > LDAP and vbscript. I have borrowed some code that supposedly works but I am > having trouble getting it to work. Can anyone help? I just want to have > users login using this page and a previous one, with a form that does a post > with logon information. If the username and password are correct then > another page will be called if it is incorrect it will take you back to the > logon page. > > Below is what I have so far. When I get to the command > > Set lobjUser = dso.OpenDSObject(ldapserver, userName, password, 0) > > I get an error saying the username or password is incorrect. Please help. > > ____________________________________________________________________________ > __ > > <%@ Language=VBScript %> > > <% > Dim UserName, Password, ldapserver, ldap_path > > 'Construct the FQDN > > ldap_path = "LDAP://server.domain.edu/cn=##,DC=domain,DC=edu" > > 'get the ldap server name into local variable by replacing the > special<BR>charcter > 'with the username > > ldapserver = Replace(ldap_path,"##",Request.Form("username")) > > > Response.Write(Request.Form("username") & "<br>") > Response.Write(ldapserver & "<br>") > > ' Connect to the LDAP Directory > > Set dso = GetObject("LDAP:") > > 'parse the username from the ldap path > > userName = Mid(ldapserver, InStr(8, ldapserver, "/") + 1) > > Response.Write(userName & "<br>") > > 'get the password > > Password = Request.Form("Password") > > 'Validate the User Name and Password > > Set lobjUser = dso.OpenDSObject(ldapserver, userName, password, 0) > > 'Response.Write(lobjUser.class) > 'Response.Write(err.description) > > > 'exit with error - Incorrect username & password - return to login.asp > page > > 'If Err.number<>0 Then > ' Response.Write "AUTHENTICATION FAILURE!" > ' Set lobjUser = nothing > ' Set dso = nothing > 'Else > ' Response.Write "SUCCESS!!" > 'End If > > 'To get information from the LDAP directory you need to know the > "attributes" > 'available and then you can reference them. Ex: > 'strUserName = lobjUser.Get("cn")> > %> > >
- Next message: Jim: "Re: LDAP Authentication"
- Previous message: Jason S: "Re: Probable Internet Explorer Problem"
- In reply to: Jim: "LDAP Authentication"
- Next in thread: Jim: "Re: LDAP Authentication"
- Reply: Jim: "Re: LDAP Authentication"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|