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

IsUserInRole problem/issue 2

Status
Not open for further replies.

johk02

Programmer
Aug 20, 2003
169
AU
Hi,
I am bit confused here - how come that this works
<cfif IsUserInRole("Level1") OR IsUserInRole("Level2")>
but this IsUserInRole("Level1,Level2") doesn't work??

Thanks
Jonas
 
because the function IsUserInRole is looking for one value. to make it easy, that's the way MM programmed the function to work. Could they have written it to accept a list and parse the list? yep, but they didn't. you can request they do so on the MM website. faq232-5731

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Actually, that's not entirely accurate. According to LiveDocs, you can have a list as long as there are no spaces in it. The catch is, the user must be in BOTH roles.
LiveDocs said:
To check if a user is in multiple roles, specify them in a comma delimited list, such as "Admin,HR". Lists with multiple roles cannot contain spaces as separators; for example, do not use "Admin, HR".



Hope This Helps!

ECAR
ECAR Technologies, LLC

"My work is a game, a very serious game." - M.C. Escher
 
Doh! My bad.

So i guess my corrected answer would be
the list doesn't work because it's the same as
<cfif IsUserInRole("Level1") AND IsUserInRole("Level2")>
not
<cfif IsUserInRole("Level1") OR IsUserInRole("Level2")>


Thanks Ecar.


We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
I had missed the catch ie that a user had to be a member of BOTH roles. I pressumed that that the user could be a member of just one of the roles.

Thanks Ecar

Jonas
 
I am not to sure if that is the case that a user have to be a member of all roles. In the application.cfm I have this code - it's getting a list of all roles to verify that someone is logged in under correct role before it process the code otherwise they get transfered to another page.
####################
<cfquery name="RS_GetAllUserLevels" datasource="#request.SiteDSN#">
SELECT tbl_usergroup.userGroup FROM tbl_usergroup
</cfquery>

<cfset request.AdminAL = Valuelist(RS_GetAllUserLevels.userGroup)>
<cfif isuserinrole("#request.AdminAL#")>
####################

And I have just assigned 1 role per user.

Jonas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top