General discussion

Locked

VBScript Error handling

By munrrob ·
I am writing a site using ASP 3.0 pages and VBScript. I am connecting to a SQL Server 2k database and running on a Windows 2k IIS server.
I am using Windows security to log people in but need to know how to capture if a user hasn't got permission to the database and show an error page telling them they do not have permissions. I need to do this in the VBScript. How do I go about this?

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by LukCAD In reply to VBScript Error handling

I am using ASP.NET technology but I was early ASP programmer too, may be it helps for you:

<%@ LANGUAGE = VBScript %>
<% Option Explicit %>

<!*************************
This sample is provided for educational purposes only. It is not intended to be
used in a production environment, has not been tested in a production environment,
and Microsoft will not provide technical support for it.
*************************>

<%
'Force Authentication if the LOGON_USER Server Variable is blank
'by sending the Response.Status of 401 Access Denied.

'Finish the Page by issuing a Response.End so that a user
'cannot cancel through the dialog box.

If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 Access Denied"
Response.End
End If
%>

<HTML>
<HEAD>
<TITLE>Login Screens</TITLE>
</HEAD>

<BODY BGCOLOR="White" TOPMARGIN="10" LEFTMARGIN="10">


<!-- Display header. -->

<FONT SIZE="4" FACE="ARIAL, HELVETICA">
<B>Login Screens</B></FONT><BR>

<HR SIZE="1" COLOR="#000000">


<!-- Display LOGON_USER Server variable. -->

You logged in as user:<B> <%= Request.ServerVariables("LOGON_USER") %></B>


<!-- Display AUTH_TYPE Server variable. -->

<P>You were authenticated using:<B> <%= Request.ServerVariables("AUTH_TYPE") %></B> authentication.</P>

</BODY>
</HTML>

Collapse -

by LukCAD In reply to

it's too hard to uderstand, if you would like another way for checking permission of user and sending special message for him, you can simply use the possability of IIS identification. I hope that you know that are three ways: form, IIS and Windows Authentication. You can send me your letter and I can propouse myself manner for that - another from traditional bat also smart.

Collapse -

by munrrob In reply to

Poster rated this answer.

Collapse -

by adasys In reply to VBScript Error handling

here is what you have to do.
Use a testuser as your userid in windows and create one in your sql but dont have right to the database.
Access the page you created and of course you will have an erro. Whis is an asp error or Transatsql error. Remember the error number. then rewrite you code with the ff. line inserted.

<%
on error resume next
this line or pff. lines your code to access the sql


if err.number = this is the number a while ago then
Response.Write("No Access")
end if

%>

Collapse -

by munrrob In reply to

Thanks for all the ideas but I was able to find the code I needed:

if objConn.State=adStateClosed then
Response.Redirect "./Error.asp"
end if

This works perfectly well when tested..

Collapse -

by munrrob In reply to VBScript Error handling

This question was closed by the author

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums