CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Multi Group Membership

Print topic Send  topic

Author Message
Brandon
Posted: 06/30/2003, 11:04 AM

With my standard ASP coding in the past I have often had need for roles based security. For instance, you might have an editor role, report access role, broadcast email role, superadmin role etc. One user might need to be in more than one role and roles aren't necessarily heiarchical. My solution was to have a string of numbers seperated by a delimiter to indicate the roles they belong to and then use instr() to look for a match. CCS is very similar to this expect that a user can only be in one role.

A slight modification to CCUserInGroups function
in common.asp allows for this functionality.
(The function is different if "Higher levels inclusive of lower levels" is checked and it wouldn't make sense to use it there).

'''Allow a user to be in multiple security groups. Enter their groups with commas dividing each.

Change this function in Common.asp
'CCUserInGroups @0-D62B622E
Function CCUserInGroups(GroupID, GroupsAccess)
Dim Result
'''If no groups have been specified with access; let all of them in.
If NOT IsEmpty(GroupsAccess) Then
'''New code to handle users being in more than one group
dim varElement
dim arrayGroups
dim varGroupID
varGroupID=cstr(GroupID)

'''If GroupID is delimited put the values in an array; otherwise put the value in first element of array
if instr(varGroupID,",")>0 then
arrayGroups=Split(varGroupID,",")
else
arrayGroups=Array(varGroupID)
end if

'''Check each array element and see if it is allowed access
For Each varElement in arrayGroups
Result = NOT (InStr(";" & GroupsAccess & ";", ";" & varElement & ";") = 0)
if Result=True then
'''Once there is a match we know they have rights
Exit For
end if
Next

'''end of new code
'''Original Code:
'''Result = NOT (InStr(";" & GroupsAccess & ";", ";" & GroupID & ";") = 0)
Else
Result = True
End If
CCUserInGroups = Result
End Function
'End CCUserInGroups
rrodgers
Posted: 06/30/2003, 11:17 AM

Thanks.
rob
Karen
Posted: 07/02/2003, 1:03 AM

I'm trying to do this with PHP/MySQL. Can anyone help? TIA!
jayme
Posted: 09/08/2003, 12:07 PM

Brandon,

I like your example. One question concerning the back-end database:

1. If you are separating group id's with a comma does this require me to
change the Group_ID field (in the database) from a number or autoid to a
text field?

The reason I ask because putting a comma (1,2) in the database's Group_ID field
will not work due to the format of the number/or autoid fields.
I understand the front-end webpage changes, but how did you account for this in the database itself? Thank you. (jayme27@hotmail.com) Jayme
Simon
Posted: 09/13/2003, 7:26 AM

Karren,

Did you manage this in PHP? I am after doing the same so would like some info please.

TA
Brandon
Posted: 09/25/2003, 7:25 AM

Yes, Group_id will need to be a text field for this to work. The function doesn't care but you obviously won't be able to put commas in to add multiple groups.

As for PHP, I haven't had a chance to rewrite it yet. If someone does please post it.

email: brandon at smpweb dot com

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.