sp_aux_checkroleperm is called as a subprocedure by many of the other system stored procedures. The initial comment block describes what it does:
1> sp_helptext sp_aux_checkroleperm
2> go
# Lines of Text
---------------
12
(1 row affected)
text
-------------------------------------------------------------------------------
----------------
/*
** SP_AUX_CHECKROLEPERM
** Checks if the user has a particular role or permission. It does this
** check depending on whether granular permissions is enabled or not. If
** it is not enabled then the role specified by @rolename will be checked
** o
therwise the permission specified by @role_perm_name will be checked.
** If a @rolename is NULL and granular permissions is not enabled or
** if granular permissions is enabled and @role_perm_name is NULL then
** it assumed that there was no role/permissi
on check required and a
** 0 is returned.
**
** Parameters:
** @rolename - Name of role to check for if granular permissions
** not enabled. If @rolename is "dbo" then we check
** to see if user_id() is 1.
**
** @role_perm_name - Name of role
or permission to check if granular
** permissions is enabled. When granular permissions is
** enabled some stored procedures require either a
** permission or a role. In the case when checking for
** a role a rolename may be passed i
n instead of a
** permission name.
**
** @dbname - If not null then pass to has_privilege as database
** name to do the permission check in.
** @gp_enabled - (output) 0 if granular permissions is not enabled
** otherwise set to 1.
** Return
s:
** 0 - User has role or permission.
** 1 - role checked and user doesn't have it.
** 2 - permission checked and user doesn't have it.
** History:
** August 2010 malloy written.
*/