Selecting users that are in multiple groups

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default Selecting users that are in multiple groups

    I am very new to ColdFusion and am having a light issue trying to select users
    that are in multiple groups...

    Basically, I want the sales people that are in the Sales group and the
    Customer group to have access to a webmail link. Users in the Customers group
    won't have the link displayed.



    <!--- only show the reports and ecom links to the customers group --->
    <!--- <cfif ListFind(ValueList(getGroups.groupID), 4)> --->
    <cfif getGroups.groupID gte 4>
    <a href="http://LINK_HERE/"><b>Food-Ecom Login</b></a><br>
    <a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
    <a href="/links.cfm"><b>Useful Links</b></a><br>

    <!--- only show the webmail link to the sales group --->
    <cfelseif getGroups.groupID gte 3>
    <a href="http://WEBMAIL_LINK/"><b>CBW Webmail</b></a><br>
    </cfif>

    jlavetan Guest

  2. Similar Questions and Discussions

    1. Selecting objects within groups
      Help! I'm using CS2 to produce an advertisement for an auto dealer. It consists of a 7x7 grid of 49 vehicles. Each vehicle space consists of a photo...
    2. [Carbon] how do i get a list of users and groups??
      hey all, i've been struggling to figure out how to get a list of users and groups like the finder's get info window displays in its ownership &...
    3. selecting ordered groups out of a table
      Rainer Gauweiler wrote: with recent_orders as ( select customer, invoice-nr, date, row_number() over (partition by customer, order by date...
    4. adding users to different groups
      Hi group, I need to add a user (myself) to a group he doesn't belong to by default. On most unices I do edit the group file and voila. On the...
    5. local users and groups
      When I try to access the Local Users and Groups, as the local administrator, there's an X, and I get an error message stating, Unable to access the...
  3. #2

    Default Re: Selecting users that are in multiple groups

    If I'm understanding you correctly, you have a list of groups that the current
    user is a member of. If the current user belongs to both the "sales" and
    "customer" group, you to want to display a "web mail" link. Otherwise, you want
    to display nothing.

    If so, one method would be to use the ListFind() method:



    <cfset salesGroupID = 3>
    <cfset customerGroupID = 4>
    <cfset memberOfGroups = "1,3,4">

    <!--- Link is displayed because user belongs to both sales and customer groups
    --->
    <cfif ListFind(memberOfGroups, salesGroupID) GT 0 AND
    ListFind(memberOfGroups, customerGroupID) GT 0>
    <a href="http://WEBMAIL_LINK/"><b>CBW Webmail</b></a><br>
    <cfelse>
    The current user has no access to Webmail
    </cfif>

    mxstu Guest

  4. #3

    Default Re: Selecting users that are in multiple groups

    Ok, that works... except that both groups have access to the webmail link...
    How can I make it so:

    If user is a member of both customer and sales group then display Link 1
    If user is a member of customer group only then display Link 2



    <cfset salesGroupID = 3>
    <cfset customerGroupID = 4>
    <cfset memberOfGroups = "1,3,4">

    <!--- only show the reports and ecom links to the customers group --->
    <cfif ListFind(memberOfGroups, customerGroupID) GT 0>
    <a href="http://LINK.com/"><b>Food-Ecom Login</b></a><br>
    <a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
    <a href="/links.cfm"><b>Useful Links</b></a><br>
    </cfif>
    <!--- Link is displayed because user belongs to both sales and customer
    groups --->
    <cfif ListFind(memberOfGroups, salesGroupID) GT 0 AND
    ListFind(memberOfGroups, customerGroupID) GT 0>
    <a href="http://WEBMAIL LINK/"><b>CBW Webmail</b></a><br>
    <cfelse>
    The current user has no access to Webmail
    </cfif>

    jlavetan Guest

  5. #4

    Default Re: Selecting users that are in multiple groups

    <cfif ListFind(memberOfGroups, customerGroupID) GT 0>
    <cfif ListFind(memberOfGroups, salesGroupID) GT 0>
    Member of "customer" and "sales" group - Display Link 1
    <cfelse>
    Member of "customer" group only - Display Link 2
    </cfif>
    </cfif>


    mxstu Guest

  6. #5

    Default Re: Selecting users that are in multiple groups

    My test user who is in the Customer group only can still see the link...



    <cfset salesGroupID = 3>
    <cfset customerGroupID = 4>
    <cfset memberOfGroups = "1,3,4">

    <cfif ListFind(memberOfGroups, salesGroupID) GT 0>
    <cfif ListFind(memberOfGroups, customerGroupID) GT 0>
    <a href="http://ecom.cooperbooth.com/"><b>Food-Ecom Login</b></a><br>
    <a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
    <a href="/links.cfm"><b>Useful Links</b></a><br>
    <a href="http://208.17.69.11:8080/"><b>CBW Webmail</b></a><br>

    <cfelse>
    <a href="http://ecom.cooperbooth.com/"><b>Food-Ecom Login</b></a><br>
    <a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
    <a href="/links.cfm"><b>Useful Links</b></a><br>
    </cfif>
    </cfif>

    jlavetan Guest

  7. #6

    Default Re: Selecting users that are in multiple groups

    If this is your test code, the user would see the link because they are a
    member of both groups (3 and 4):
    <cfset salesGroupID = 3>
    <cfset customerGroupID = 4>
    <cfset memberOfGroups = "1,3,4">

    I think you switched the example code around and reversed the logic. Try
    attached.



    <cfset salesGroupID = 3>
    <cfset customerGroupID = 4>
    <!--- This user is ONLY a member of customer group --->
    <cfset memberOfGroups = "4">

    <!--- user IS a member of customer group --->
    <cfif ListFind(memberOfGroups, customerGroupID) GT 0>
    <a href="http://ecom.cooperbooth.com/"><b>Food-Ecom Login</b></a><br>
    <a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
    <a href="/links.cfm"><b>Useful Links</b></a><br>
    <!--- user IS also a member of sales group --->
    <cfif ListFind(memberOfGroups, salesGroupID) GT 0>
    <a href="http://WEBMAIL LINK/"><b>CBW Webmail</b></a><br>
    </cfif>
    </cfif>

    mxstu Guest

  8. #7

    Default Re: Selecting users that are in multiple groups

    First, I want to say thanks for helping me out... :-)

    With the latest code... neither user can see the link...

    user test is in group 4
    user sales_test is in group 3 and 4

    jlavetan Guest

  9. #8

    Default Re: Selecting users that are in multiple groups

    Not a problem. The code worked fine for me when I tested each of the different
    possibilities. A few things you should check:

    1) Did you output all of the variables to make sure they contain the correct
    values?
    2) Are there any spaces in between the list values? You may need to remove
    them first. Use Replace() function
    3) ListFind() assumes that the list delimiter is a comma, so if you're using a
    different delimiter, you need to specify it.


    mxstu Guest

  10. #9

    Default Re: Selecting users that are in multiple groups

    Dumb question, but would it matter that group IDs are in the database (MS Access)? so, doing the cfset command is causing the problem
    jlavetan Guest

  11. #10

    Default Re: Selecting users that are in multiple groups

    I'm not sure which CFSET statement you're referring to, but the sample code was
    just an example. You need to replace this line:
    <cfset memberOfGroups = "1,3,4">

    with whatever code you're using to create the actual list, such as:

    <cfset memberOfGroups = ValueList(getGroups.groupID)>


    mxstu Guest

  12. #11

    Default Re: Selecting users that are in multiple groups

    Solved :-)
    Thanks again for your help :-)

    Ok, here is the final working code...



    <cfset salesGroupID = 3>
    <cfset customerGroupID = 4>
    <!--- This user is ONLY a member of customer group --->
    <cfset memberOfGroups = ValueList(getGroups.groupID)>

    <!--- user IS a member of customer group --->
    <cfif ListFind(memberOfGroups, customerGroupID) GT 0>
    <a href="http://ecom.cooperbooth.com/"><b>Food-Ecom Login</b></a><br>
    <a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
    <a href="/links.cfm"><b>Useful Links</b></a><br>
    <!--- user IS also a member of sales group --->
    <cfif ListFind(memberOfGroups, salesGroupID) GT 0>
    <a href="http://WEBMAIL LINK/"><b>CBW Webmail</b></a><br>
    </cfif>
    </cfif>

    jlavetan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139