使用数组来限制访问 [英] Use array to limit access

查看:68
本文介绍了使用数组来限制访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试限制对我们内联网上某些页面的访问,并且使用以下代码已经

这样做,


dim登录, L,LL,StringLen,NTUser

设置登录= Request.ServerVariables(" LOGON_USER")

L = Len(登录)

LL = InStr(登录,\)

StringLen = L-LL

NTUser =(右(登录,StringLen))

如果NTUser<" DLaing"那么

如果NTUser<" DLowe"然后

如果NTUser<" DWoods"然后

Response.Redirect(" http://swvtc06/swvtc/default.asp")

结束如果

结束如果

结束如果


问题是,如果我想添加更多用户来访问该页面,那么我需要添加另一个IF和END IF行。我想以某种方式使用数组实现

。例如,将用户名放入

数组,然后如果匹配则允许访问,如果不匹配则重定向。我知道这不是一种防弹方式,并且有更强大的

方法,但这对我们的用户群和我们的需求非常有效。我有一个非常糟糕的大脑阻滞的情况,并且不能,对于我的生活,

想出这个。


谢谢,

画了

I am trying to limit access to certain pages on our intranet, and have been
using the following code to do so,

dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerVariables("LOGON_USER")
L=Len(Login)
LL=InStr(Login, "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))

If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redirect("http://swvtc06/swvtc/default.asp")
End If
End If
End If

The problem is that if I want to add more users to have access to the page,
then I have to add another IF and END IF line. I would like to implement
some way to do this using an array. For instance put the usernames into the
array and then if it matches then allow access, if not then redirect. I
know this is not a bulletproof way to do this, and there are more robust
methods, but this works very well for our user base and our needs. I am
having a really bad case of brain block, and cannot, for the life of me,
figure this out.

Thanks,
Drew

推荐答案

" Drew" < dr ******** @ swvtc.dmhmrsas.virginia.govwrote in message

news:OZ ************** @ TK2MSFTNGP05.phx .gbl ...
"Drew" <dr********@swvtc.dmhmrsas.virginia.govwrote in message
news:OZ**************@TK2MSFTNGP05.phx.gbl...

我试图限制访问我们内联网上的某些页面,并且有
I am trying to limit access to certain pages on our intranet, and have




been


使用以下代码执行此操作,


dim登录,L,LL,StringLen,NTUser

设置登录= Request.ServerVariables(" LOGON_USER")

L = Len(登录)

LL = InStr(登录," \\ \\)

StringLen = L-LL

NTUser =(右(登录,StringLen))


如果NTUser< ;" DLaing"那么

如果NTUser<" DLowe"然后

如果NTUser<" DWoods"然后

Response.Redirect(" http://swvtc06/swvtc/default.asp")

结束如果

结束如果

结束如果


问题是如果我想添加更多用户来访问
using the following code to do so,

dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerVariables("LOGON_USER")
L=Len(Login)
LL=InStr(Login, "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))

If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redirect("http://swvtc06/swvtc/default.asp")
End If
End If
End If

The problem is that if I want to add more users to have access to the



页面,

page,


然后我必须添加另一个IF和END IF行。我想以某种方式使用数组实现

。例如,将用户名放入
then I have to add another IF and END IF line. I would like to implement
some way to do this using an array. For instance put the usernames into




the


数组然后如果匹配则允许访问,如果然后不重定向。我知道这不是一种防弹方式,并且有更强大的

方法,但这对我们的用户群和我们的需求非常有效。我有一个非常糟糕的大脑阻滞的情况,并且不能,对于我的生活,

想出这个。
array and then if it matches then allow access, if not then redirect. I
know this is not a bulletproof way to do this, and there are more robust
methods, but this works very well for our user base and our needs. I am
having a really bad case of brain block, and cannot, for the life of me,
figure this out.



首先让我们处理那个用户名:/

函数GetUser()

sLogon = Request.ServerVariables( LOGON_USER)


GetUser = Mid(sLogon,InStr(sLogon," \"))


结束函数


注意没有设置获取LOGON_USER和中间第三个参数是可选的

当丢失时意味着''到字符串末尾''。


Const gcsAllowedUser =" DLang; DLowe; DWood;


如果Instr(gcsAllowedUsers,GetUser()&" ;;")= 0那么

Response.Redirect(" http ://swvtc06/swvtc/default.asp")

结束如果


如果你想限制一组页面,那么将上面的代码放入ASP

它自己的页面,在你的网络根目录中的priviledged.asp然后在你要保护的每个

页面中: -


<! - #include virtual =" /priviledged.asp" - >

-

Anthony Jones - MVP ASP / ASP.NET


First lets deal with that user name thing:-

Function GetUser()

sLogon = Request.ServerVariables("LOGON_USER")

GetUser = Mid(sLogon, InStr(sLogon, "\"))

End Function

Note no Set when getting LOGON_USER and Mid third parameter is optional
which when missing means ''to the end of the string''.

Const gcsAllowedUser = "DLang; DLowe; DWood;"

If Instr(gcsAllowedUsers, GetUser() & ";") = 0 Then
Response.Redirect("http://swvtc06/swvtc/default.asp")
End If

If you want to restrict a set of pages then put the above code in an ASP
page of its own, say priviledged.asp in the root of your web then in each
page you want to protect:-

<!-- #include virtual="/priviledged.asp" -->
--
Anthony Jones - MVP ASP/ASP.NET


" Anthony Jones" ; < An*@yadayadayada.com写信息

新闻:uV ************* @ TK2MSFTNGP06.phx.gbl ...
"Anthony Jones" <An*@yadayadayada.comwrote in message
news:uV*************@TK2MSFTNGP06.phx.gbl...

" Drew" < dr ******** @ swvtc.dmhmrsas.virginia.govwrote in message

news:OZ ************** @ TK2MSFTNGP05.phx .gbl ...
"Drew" <dr********@swvtc.dmhmrsas.virginia.govwrote in message
news:OZ**************@TK2MSFTNGP05.phx.gbl...

>我试图限制对我们内联网上某些页面的访问,并且有
>I am trying to limit access to certain pages on our intranet, and have




been


>使用以下代码执行此操作,

dim Login,L,LL,StringLen,NTUser
设置登录= Request.ServerVariables(" LOGON_USER")
L = Len(登录)
LL = InStr(登录,\)
StringLen = L- LL
NTUser =(右(登录,StringLen))

如果NTUser<" DLaing"然后
如果NTUser<" DLowe"然后
如果NTUser<" DWoods"然后
Response.Redirect(" http://swvtc06/swvtc/default.asp")
结束如果
结束如果
结束如果

问题是如果我想添加更多用户来访问
>using the following code to do so,

dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerVariables("LOGON_USER")
L=Len(Login)
LL=InStr(Login, "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))

If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redirect("http://swvtc06/swvtc/default.asp")
End If
End If
End If

The problem is that if I want to add more users to have access to the



页面,

page,


>然后我必须添加另一个IF和END IF行。我想用某种方式实现
使用数组。例如,将用户名放入
>then I have to add another IF and END IF line. I would like to implement
some way to do this using an array. For instance put the usernames into




the


>数组然后如果匹配则允许访问,如果没有那么重定向。我知道这不是一种防弹方式,并且有更强大的方法,但这对我们的用户群和我们的需求非常有效。我有一个非常糟糕的大脑阻滞的情况,并且不能,对于我的生活,
想出来。
>array and then if it matches then allow access, if not then redirect. I
know this is not a bulletproof way to do this, and there are more robust
methods, but this works very well for our user base and our needs. I am
having a really bad case of brain block, and cannot, for the life of me,
figure this out.




首先让我们处理那个用户名的事情: -


函数GetUser()

sLogon = Request.ServerVariables(" LOGON_USER" )


GetUser = Mid(sLogon,InStr(sLogon,\))


结束功能


注意没有设置获取LOGON_USER和中间第三个参数是可选的

当丢失时意味着''到字符串末尾''。


Const gcsAllowedUser =" DLang; DLowe; DWood;


如果Instr(gcsAllowedUsers,GetUser()&" ;;")= 0那么

Response.Redirect(" http ://swvtc06/swvtc/default.asp")

结束如果


如果你想限制一组页面,那么将上面的代码放入ASP

它自己的页面,在你的网络根目录中的priviledged.asp然后在你要保护的每个

页面中: -


<! - #include virtual =" /priviledged.asp" - >


-

Anthony Jones - MVP ASP / ASP.NET



First lets deal with that user name thing:-

Function GetUser()

sLogon = Request.ServerVariables("LOGON_USER")

GetUser = Mid(sLogon, InStr(sLogon, "\"))

End Function

Note no Set when getting LOGON_USER and Mid third parameter is optional
which when missing means ''to the end of the string''.

Const gcsAllowedUser = "DLang; DLowe; DWood;"

If Instr(gcsAllowedUsers, GetUser() & ";") = 0 Then
Response.Redirect("http://swvtc06/swvtc/default.asp")
End If

If you want to restrict a set of pages then put the above code in an ASP
page of its own, say priviledged.asp in the root of your web then in each
page you want to protect:-

<!-- #include virtual="/priviledged.asp" -->
--
Anthony Jones - MVP ASP/ASP.NET



谢谢Anthony,看起来效果很好......我不会在所有页面上使用它,

只是一些,这将很有效!


谢谢,

Drew

Thanks Anthony, that looks to work great... I don''t use this on all pages,
just a few and this will work great!

Thanks,
Drew


我会将用户名存储在数据库而不是ASP页面中的数组中

你必须维持。


杰夫


" Drew" < dr ******** @ swvtc.dmhmrsas.virginia.govwrote in message

news:OZ ************** @ TK2MSFTNGP05.phx .gbl ...
I would store usernames in a database instead of an array in an ASP page
that you would have to maintain.

Jeff

"Drew" <dr********@swvtc.dmhmrsas.virginia.govwrote in message
news:OZ**************@TK2MSFTNGP05.phx.gbl...

>我试图限制对我们内联网上某些页面的访问,并且已经使用以下代码来执行此操作,


dim登录,L,LL,StringLen,NTUser

设置登录= Request.ServerVariables(" LOGON_USER")

L = Len(登录)

LL = InStr(登录,\)

StringLen = L-LL

NTUser =(右(登录,StringLen))


如果NTUser<" DLaing"那么

如果NTUser<" DLowe"然后

如果NTUser<" DWoods"然后

Response.Redirect(" http://swvtc06/swvtc/default.asp")

结束如果

结束如果

结束如果


问题是,如果我想添加更多用户来访问

页面,那么我必须添加另一个IF和END IF行。我想使用数组实现某种方式来实现
。例如,将

用户名放入数组中然后如果匹配则允许访问,如果不是,那么
然后重定向。我知道这不是一种防弹方式,并且

是更强大的方法,但这对我们的用户群非常有效,并且我们需要。我有一个非常糟糕的大脑阻滞的情况,并且不能,因为我的生活,想出这个。


谢谢,

Drew
>I am trying to limit access to certain pages on our intranet, and have been
using the following code to do so,

dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerVariables("LOGON_USER")
L=Len(Login)
LL=InStr(Login, "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))

If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redirect("http://swvtc06/swvtc/default.asp")
End If
End If
End If

The problem is that if I want to add more users to have access to the
page, then I have to add another IF and END IF line. I would like to
implement some way to do this using an array. For instance put the
usernames into the array and then if it matches then allow access, if not
then redirect. I know this is not a bulletproof way to do this, and there
are more robust methods, but this works very well for our user base and
our needs. I am having a really bad case of brain block, and cannot, for
the life of me, figure this out.

Thanks,
Drew



这篇关于使用数组来限制访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆