Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi and thanks for reading.
I have some asp code here in a login script which validates a user against our Active Directory account info. It works great as long as I enter a correct username and password, but as soon as I enter a bogus password in there it gives me the following error:
error '80070520'
/employees/login.asp, line 22Here's my code:
============================================================================
strADsPath = "alongdomainname.com"
strPassword = Request.Form("Password")
strUserName = Request.Form("UserName")if (not strUserName= "") then
strADsPath = "WinNT://" & strADsPath
Dim oADsObject
Dim tempstr
tempstr = strDomain & "\" & strUserNameSet oADsObject = GetObject(strADsPath)
Dim strADsNamespace
Dim oADsNamespace
strADsNamespace = left(strADsPath, instr(strADsPath, ":"))
set oADsNamespace = GetObject(strADsNamespace)
'************ This is line 22:
Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, tempstr, strPassword, 0)
if not (Err.number = 0) then
Response.Write "Please provide a correct login name and password.<br />"
Response.Write err.description & ""
if err.number = -2147022987 then
Response.write "<strong>Your account has been locked!</strong>"
end if
else
'Set session variables and show the page to the member
========================================================================So how come it isn't catching this error at if not (Err.number = 0) then ... ?
The only thing I could find on this error number was a vague reference about some servers not accepting domain names longer than 16 characters, which it is. Anyone have a clue?

Just a thought:
You might want to make the code a little more robust by using something like "On error Goto errorLabel" instead of the Resume Next statement.
Then, someplace in your code add a label named 'errorLabel' and output some text saying something about bad passwords or just a generic error statement. Right after this put a "Response.End" statement to end the code execution.
This makes the code cleaner and less prone to security issues in my opinion.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |