Skip to content

Instantly share code, notes, and snippets.

@andyhuey
Created March 3, 2014 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyhuey/9326912 to your computer and use it in GitHub Desktop.
Save andyhuey/9326912 to your computer and use it in GitHub Desktop.
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