boolean expression evaluation algorithm

S

Simon Wigzell

A client wants have acess to an online databases records controlled by group
strings and evaluation strings e.g., each use would have in his client
record a group string like this:

[ROOT][ADMIN][ACCOUNTING][ABC PRODUCTS]

And each record in a database would have an evaluation string like this :

([ROOT] OR [ADMIN] OR [ACCOUNTING] OR [FINANCE]) AND [ABC PRODUCTS] OR
[ACME]) etc.

No limit to the number of groups or the complexity of the evaluation
expression. I need an asp function that I will just pass the group string
and the evaluation string and it will return True or False as to whether the
client can view that particular record. I can't find anything in ASP on the
internet though this must be a common database control method for
non-browser applications? Has anyone done anything like this in ASP? Thanks!
 
B

Bullschmidt

<<
A client wants have acess to an online databases records controlled by
group
strings and evaluation strings e.g., each use would have in his client
record a group string like this:

[ROOT][ADMIN][ACCOUNTING][ABC PRODUCTS]

And each record in a database would have an evaluation string like this
:

([ROOT] OR [ADMIN] OR [ACCOUNTING] OR [FINANCE]) AND [ABC PRODUCTS] OR
[ACME]) etc.

No limit to the number of groups or the complexity of the evaluation
expression. I need an asp function that I will just pass the group
string
and the evaluation string and it will return True or False as to whether
the
client can view that particular record. I can't find anything in ASP on
the
internet though this must be a common database control method for
non-browser applications? Has anyone done anything like this in ASP?
Thanks!
Here's something like what I've often used to make sure someone is
allowed to view a page:

' If not valid user level.
If Not jpsvbIsInList("User;Admin", Session("UserLevel"), ";", True) Then
Response.Redirect mstrSiteMainSecure & "/login.asp"
End If

And later in the page's SQL statement I might actually used the CustID
of the user too.

And here is the custom jpsvbIsInList() function:

Function jpsvbIsInList(pvarList, pvarItem, pstrSeparator,
pbolIsCaseSensitive)
' Purpose: See if item is in list.
' Remarks: Typical separator can be ; or even multiple chars such as
comma space.

' Dim var.
Dim varItem
Dim varList
Dim intCompare

' Set var.
' (Uses VB constants.)
varItem = CStr(pvarItem)
varList = CStr(pstrSeparator & pvarList & pstrSeparator)
If pbolIsCaseSensitive Then
intCompare = vbBinaryCompare
Else
intCompare = vbTextCompare
End If

' Return val.
If InStr(1, varList, pstrSeparator & pvarItem & pstrSeparator,
intCompare) > 0 Then
jpsvbIsInList = True
Else
jpsvbIsInList = False
End If
End Function

Hope this helps,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Demo, ASP Bar Chart Tool...
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,476
Members
44,896
Latest member
PenniGowin

Latest Threads

Top