Skip to content

Instantly share code, notes, and snippets.

@andyhuey
Created March 3, 2014 15:09
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/9326939 to your computer and use it in GitHub Desktop.
Save andyhuey/9326939 to your computer and use it in GitHub Desktop.
isUserInRole - good
/// <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