Cheking if a user is in a specific group

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Cheking if a user is in a specific group

Postby amason » Fri Apr 28, 2006 6:59 am

Hi,

Couldn't find this mentioned anywhere in the forum... probably too easy ;)

I want to make a method that checks if the current user is in a specific group.

for example:

function checkGroup(GroupName){
if current user is in GroupName, return true;
}

how would I do that?

THanks,

Andrew
amason
 
Posts: 138
Joined: Mon Jan 16, 2006 12:12 am

Postby automazione » Fri Apr 28, 2006 10:33 am

While the Servoy dev-team 8) does not add a new function... this one may work for you:

Code: Select all
var group_id   = security.getGroupId(arguments[0]) ; // the id of the group name passed as parameter
var user_groups = security.getUserGroups(); // all the groups associated to the current user
for ( var i = 1 ; i <= user_groups.getMaxRowIndex() ; i++ )
{
   if (group_id  == user_groups.getValue(i,1)) return true;
}
return false;


just call it passing a text var containing the group name to check
Enrico Arata
Servoy Italia
automazione
 
Posts: 366
Joined: Thu Apr 24, 2003 11:37 am
Location: Torino, Italy


Return to How To

Who is online

Users browsing this forum: No registered users and 6 guests