Stop ASP Page on Error

S

- Steve -

How do you do the following?

if(true)
response.write "There was a problem."
***STOP HERE***

more code
more code
more code
 
R

Ray at

On Error Resume Next

If Err.Number <> 0 Then
Response.Write "There was a problem."
'''close and kill connections/objects; other memory cleanup as necessary
Response.End
End If

Ray at work
 
S

- Steve -

Okay perfect. I didn't have the On Error Resume Next, so it was failing
before I could gracefully kill it.

How do I handle this though?

Const LDAP_ALREADY_EXISTS = &h80071392

Set objUser = objOU.Create("User", "CN=" & strFirstName & " " & strLastName)
objUser.Put "samAccountName", strUser
objUser.Set

If Err.Number = LDAP_ALREADY_EXISTS
Then WScript.Echo "The user account already exists."
response.end
End If

The If statment is never true. (It works fine in a regular VB script, but
put it in ASP and it falls apart) If I try to create an account with the
same username it just keeps on going, even outputing the message that the
account was created succesfully (at the end of the script.)
 
R

Ray at

I don't know if this is what you'll want, but you could simplify it and do:

On Error Resume Next
Set objUser = GetObject("WinNT://CompOrDomainName/TheUsersSAMname,user")
bUserExists = IsEmpty(objUser)
Set objUser = Nothing
On Error Resume 0

If bUserExists Then
response.write "User exists."
Else
''your code
End If

Ray at home
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top