Created
March 3, 2014 15:09
-
-
Save andyhuey/9326939 to your computer and use it in GitHub Desktop.
isUserInRole - good
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> | |
/// ajh 2014-02-12: previous method req'd admin perm. to run. Doh! | |
/// </remarks> | |
public static boolean isUserInRole(UserId axUserId, container roleNames) | |
{ | |
SecurityUserRole securityUserRole; | |
SecurityRole securityRole; | |
while select AotName from securityRole | |
join securityUserRole | |
where securityUserRole.User == axUserId | |
&& securityUserRole.SecurityRole == securityRole.RecId | |
{ | |
if (conFind(roleNames, securityRole.AotName)) | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment