UFN_SECURITY_APPUSER_GRANTED_KPI

Returns true if user has been granted and not denied the KPI for a system role

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@APPUSERID uniqueidentifier IN
@KPICATALOGID uniqueidentifier IN

Definition

Copy


CREATE function dbo.UFN_SECURITY_APPUSER_GRANTED_KPI
(@APPUSERID uniqueidentifier,@KPICATALOGID uniqueidentifier)
returns bit
as
/*
Returns true if user has been granted and not denied the KPI for a System Role.
*/
begin
    --If at least one grant and no deny then return true

    --otherwise, false

    declare @grant bit;
    set @grant=0;

    select @grant = ISSYSADMIN from dbo.APPUSER where ID = @APPUSERID;

    if @grant = 0
        begin
            --order by GRANTORDENY, deny will be first.

            select top 1 @grant=GRANTORDENY
            from dbo.V_SECURITY_SYSTEMROLEASSIGNMENT_USER_KPI
            where APPUSERID = @APPUSERID
            and KPICATALOGID=@KPICATALOGID                
            order by GRANTORDENY ASC;
        end


    return @grant;

end