A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: T-SQL: User, Login and Role Functions

has_role()

The Role Function has_role() checks whether a user has been granted the role listed in the parameter "role_name", i.e. whether he owns the corresponding role specific privileges. This function is available in ASE® starting with version 15.0. Sybase recommends to use the function has_role() instead of using the proc_role() function.

The function has_role() can return three different integer values (0,1 and 2). The values depend on whether the role listed in the parameter "role_name" has been granted to the user and whether it is active or not. The return value is "0" if the listed role has not been granted or, if it has been granted but is not an active role for this user. The return value is "1" if the listed role has been granted and is active for the user. The return value is "2" if the user has been granted an active role, which is contained in the role given in the parameter "role_name".

Syntax of the Role Function has_role()

    has_role("role_name"[, 0])
    

The parameter of the Role Function has_role()

role_name
The parameter "role_name" is a placeholder for a role.

0
The parameter "0" is an optional value to suppress "auditing" .

Example for the Role Function has_role()

    select has_role("sso_role", 0)
go
-----
1

This shows that the user has been granted the active role of the "System Security Officer".

See also:
alter role,
create role,
drop role,
grant role,
revoke role,
set role,
proc_role(),
mut_excl_roles(),
role_contain(),
role_id(),
role_name(),
show_role(),
sp_activeroles,
sp_displayroles,
sp_role,
suser_id(),
suser_name(),
user,
user_id(),
user_name(),
valid_user() and
Functions.