Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
isUserInRole - bad
/// <summary>
/// return true is the specified user is in any of the roles in the roleNames container.
/// </summary>
/// <param name="axUserId">
/// AX user id, e.g. curUserId()
/// </param>
/// <param name="roleNames">
/// container of role names to check. (use role NAME, not label.)
/// </param>
/// <returns>
/// true if user is in ANY of the specified roles.
/// </returns>
/// <remarks>
///
/// </remarks>
public static boolean isUserInRole(UserId axUserId, container roleNames)
{
SysUserManagement userManagement = new SysUserManagement();
List roleList = userManagement.getRolesForUser(axUserId);
ListEnumerator listEnum = null;
boolean isInRole = false;
str roleStr = '';
if (!roleList)
return false;
listEnum = roleList.getEnumerator();
while (listEnum.moveNext())
{
if (conFind(roleNames, listEnum.current()))
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.