|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧Theneedforasecuritysystemisobviousifyourpagesincludesensitiveinformation.
Thissampleshowsyouhowtosetupsomeofyourpagestoaskforloginiftheuserhasnotloggedinyet.
2eNetWorX/devsiteusesthiskindofprotectionforinteractivepagesandfiledownloads.
Letsassumethatwehaveapagewherethevisitorscanaskquestions.Wewanttomakesurethattheuser
hasloggedinbeforebeingabletoaskaquestion.
Iftheuserhasnotloggedinyet,wewillaskforalogin.Afterasuccessfullogin,wewillredirectthe
usertothepagerequested.
First,wewillhaveacommonfiletocheckforlogin.Youneedtoincludethisfileintoallthepages
thatrequirelogin.
security.asp
<%
bLoggedIn=(len(session("UserName"))>0)
ifbRequireLoginthen
Loginrequired
ifNotbLoggedInthen
Notloggedin,askforlogin
response.redirect"login.asp?comebackto="&_
request.servervariables("script_name")&"?"&_
server.urlencode(request.querystring)
Notehowweconstructthepagetocomeback
endif
endif
%>
login.asp
Firstthingtodoinourlogin.asppageistogetthepagewheretheuserisredirectedfrom.Thevariable
sRefererisusedtoredirectbacktothepagetheuserhascomefrom.
sGoBackTovariablewillusedinthe<form>tagforpersistingthislocationwhenwesubmittheloginform.
<%
ifrequest("comebackto")""then
sReferer=request("comebackto")
sGoBackTo="?"&request.querystring
endif
ifrequest("cmdLogin")""then
LoginFormsubmitted
sUserName=request("txtUserName")
sPassword=request("txtPassword")
Checkforusernameandpassword
ifsUserName="bill"AndsPassword="gates"then
bLoginSuccessful=True
endif
session("UserName")=sUserName
Afterasuccessfullogin,letssendtheuser
backtothepagerequested.ThevariablesReferer
holdsthepagetogoback,ifitisempty,weshould
redirecttheusertoourdefaultpage.
ifsReferer=""then
response.redirect"index.asp"
else
response.redirectsReferer
endif
else
DisplaytheLoginForm
%>
<formaction="login.asp<%=sGoBackTo%>"method="post">
<inputtype="text"name="txtUserName"><br>
<inputtype="password"name="txtPassword"><br>
<inputtype="submit"name="cmdLogin"><br>
</form>
<%
endif
%>
testpage.asp
Now,allyouneedtodoissettingbRequireLogintoTrueandincludingthesecurity.aspfile.
<%
bRequireLogin=True
%>
<!--#includefile="security.asp"-->
Usersshouldbeloggedintoseethistext.
IhopethissamplegivesyouaquickoverviewofasimplesecuritysystemimplementationwithASP.
Youarealwayswelcometoexpressyourfeedback!
byHakanEskici
</p>强大的可扩展性。ASP具有强大的扩展性,可以实现与多种网络、硬件设备的连接:通过专用的通讯线路远程接入企业;通过远程拨号服务器为远程拨号客户提供服务;通过WAP为移动电话互联网客户服务。 |
|