UFN_SECURITY_APPUSER_GRANTED_CODETABLEENTRYUPDATE_IN_SYSTEMROLE

Returns true if the user has been granted and not denied the right to update entries in a given code table.

Return

Return Type
bit

Parameters

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

Definition

Copy


CREATE function dbo.UFN_SECURITY_APPUSER_GRANTED_CODETABLEENTRYUPDATE_IN_SYSTEMROLE
(
    @APPUSERID uniqueidentifier,
    @CODETABLEID uniqueidentifier
)
returns bit
as
/*
Returns true if user has been granted and not denied the permission to add an entry to a given code table.
*/
begin
    --If at least one grant and no deny then return true

    --otherwise, false

    declare @updateAllowed bit;
    set @updateAllowed = 0;

    declare @rulingCode tinyint;

    select top(1) @rulingCode = UPDATEPERMISSIONCODE
    from dbo.V_SECURITY_SYSTEMROLEASSIGNMENT_USER_CODETABLE
    where APPUSERID = @APPUSERID
        and CODETABLECATALOGID = @CODETABLEID        
    order by UPDATEPERMISSIONCODE desc

    if @rulingCode = 1    --Granted

        set @updateAllowed = 1;

    return @updateAllowed;
end