Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LDAP authentication in asp-unable to open the URL

Status
Not open for further replies.

nthouse

Programmer
Dec 30, 2014
1
IT
I have used below code to authenticate.But not able to open the URL after providing username and password.


Function LDAPLogIn(uid,pwd,byref messagelog, byref codiceRitorno)
On error Resume Next

'response.write "*****************************************<br>"
'response.write "************** LDAPLogIn ****************<br>"
'response.write "*****************************************<br>"
' Const ADS_NO_AUTHENTICATION = 10
Const ADS_SECURE_AUTHENTICATION = &H1
Const ADS_USE_ENCRYPTION = &H2
Const ADS_USE_SSL = &H2
Const ADS_READONLY_SERVER = &H4
Const ADS_PROMPT_CREDENTIALS = &H8
Const ADS_NO_AUTHENTICATION = &H10
Const ADS_FAST_BIND = &H20
Const ADS_USE_SIGNING = &H40
Const ADS_USE_SEALING = &H80
Const BasePathOPEN = "LDAP://directory.services.external.local/o=telecom italia group"

Dim scad

Set objShell = CreateObject("Wscript.Shell")
lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")

If UCase(TypeName(lngBiasKey)) = "LONG" Then
lngBias = lngBiasKey
ElseIf UCase(TypeName(lngBiasKey)) = "VARIANT()" Then
lngBias = 0
For k = 0 To UBound(lngBiasKey)
lngBias = lngBias + (lngBiasKey(k) * 256^k)
Next
End If

Dim errorMessage
Set usr = Nothing
UserPath = searchDN("uid", uid, BasePathOPEN, "AdsPath", "", "",errorMessage)

If trim(userPath) = "" Then
codiceRitorno = 1
messagelog = errorMessage
'response.write "LDAPLogIn - User path non trovato"
' LDAPLogIn = "UTENTE NON AUTENTICATO (User errata)"
' LDAPLogIn = LDAPLogIn & errorMessage
Else
gga = Split (userPath, "/", -1, 1)
dn = gga(3)
err = 0
Set oNamespOPEN = GetObject("LDAP:")
Set usr = oNamespOPEN.OpenDSObject(userPath,dn,"",&H10)
Set scad = nothing
Set scad = usr.get("tigPwdExpirationDate")
dtmPwdLastSet = ""
dtmPwdLastSet = Integer8Date(scad, lngBias)

' Verifico scadenza password
diff = -1
diff = datediff("s", dtmPwdLastSet,now())
If diff < 0 Then ' password non scaduta
err = 0
' Verifico correttezza password
Set usr1 = oNamespOPEN.OpenDSObject(userPath,dn,pwd,0)
If Err <> 0 then
codiceRitorno = 3
messagelog = Err.Description
'response.write "LDAPLogIn - Password errata"
' LDAPLogIn = "UTENTE NON AUTENTICATO (Password errata): "& Err.Description ' password errata
Else
codiceRitorno = 0
'response.write "LDAPLogIn - Password corretta"
' LDAPLogIn = "UTENTE AUTENTICATO" ' password corretta
End If
Else ' password scaduta
codiceRitorno = 2
'response.write "LDAPLogIn - Password scaduta"
' LDAPLogIn = "La password usata risulta scaduta"
'Response.Redirect(" End If
End If
End Function

Kindly help to correct
 
First thing I would try is to comment out the "on error resume next", and see what runtime errors come up
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top