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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change code for use in an include file 2

Status
Not open for further replies.

tamnet

IS-IT--Management
Jun 2, 2005
31
GB
I have the following code which determines the username login I then use this to restrict users to certain pages however, at the moment i have to place the code on every page that i need to use it on. Could someone tell me if it is possible to change it so that i could use it in an include page and just call it when needed.

Code:
<%
dim userName
userName = Split(ucase(Request.ServerVariables("LOGON_USER")),"\")

' all comparison variables now use uppercase
' and domain and username is in an array
if userName(0) = "SOMEDOMAIN-UK" then

select case userName(1)
case "TOM", "DICK", "HARRY
%>
  <table width="90%" height="20%" border="0" align="center" cellpadding="1" cellspacing="1">
  <tr> 
    <td height="23" align="center" valign="middle" class="style11 style14"> 
      MC LOAD PLANNING</td>
  </tr>
    <tr> 
    <td height="22" align="center" valign="middle"> <div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"></font><span>
	<span class="style8"><span class="style9">
	<a href="../LoadingHome.htm" target="_parent" class="buttonStyle">Loadings</a>
	<a href="MCOrdersMart.asp" target="mainFrame" class="buttonStyleMed">Martin 616</a>
	<a href="MCOrdersM924.asp" target="mainFrame" class="buttonStyleMed">Martin 924</a>
	<a href="MCOrdersPrime.asp" target="mainFrame" class="buttonStyleSmall">Prime</a>

	</span></span></span><span class="style9"></font></span></div></td>

  </tr>
</table>
<%case else%>
<div align="center">
<table width="90%" height="20%" border="0" align="center" cellpadding="1" cellspacing="1">
  <tr> 
    <td height="23" align="center" valign="middle" class="style11 style14"> 
      MC LOAD PLANNING</td>
  </tr>
    <tr> 
    <td height="22" align="center" valign="middle">
"You do not have access to these pages</td>

  </tr>
</table>
<%
end select

end if
%>



Regards

Paul
 
Just save the entire text above as ident.asp in your root directory then include this line in each page where you want the script to be:

<!-- #INCLUDE FILE="ident.asp" -->

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
you dont change the code in this situation...just put all the into a new asp file that you want to reuse again and again in different asp pages...

as John stated...just include the file that you want to reuse in your asp pages...

-DNG
 
Guys thanks for that, stars for you both


Regards

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top