Re: LDAP Authentication

From: Mark Schupp (mschupp_at_ielearning.com)
Date: 05/29/03


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 &amp; 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")>
> %>
>
>


Relevant Pages

  • LDAP Authentication
    ... I am trying to create an asp page that will authenticate against AD using ... LDAP and vbscript. ... If the username and password are correct then ... Set lobjUser = dso.OpenDSObject ...
    (microsoft.public.inetserver.iis.security)
  • Cannot Login using GUI
    ... I cannot login to either my user account ... changed my authentication settings to use LDAP. ... "Incorrect username or password ..". ...
    (RedHat)
  • Problem handling Login control Authenticate event
    ... login process. ... required for login… they have a username, password, and another “location ... and when the extra input field is submitted ... for the users where this concatenation of the two input field ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: unable to login as user
    ... unable to login as user ... Log in as root and look closely at the user account. ... the system just seems to hang and then go back to the username ...
    (RedHat)
  • Re: Unable to log into OWA despite using correct username and pass
    ... the OWA interface despite using the correct username and password. ... OWA login page is displayed correctly but when trying to login users get ... "You could not be logged on to Outlook Web Access. ... The issue is affecting all accounts including the 'Administrator' ...
    (microsoft.public.exchange.clients)