Created
March 3, 2014 15:07
-
-
Save andyhuey/9326912 to your computer and use it in GitHub Desktop.
isUserInRole - bad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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