UFN_SECURITY_APPUSER_GRANTED_SITE

Return

Return Type
bit

Parameters

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

Definition

Copy


create function dbo.UFN_SECURITY_APPUSER_GRANTED_SITE
(
  @APPUSERID uniqueidentifier,
  @SITEID uniqueidentifier
)
returns bit as

begin
  if exists
  (
    select 1
    from dbo.SYSTEMROLEAPPUSER
    where SYSTEMROLEAPPUSER.APPUSERID = @APPUSERID
    and (
      (SYSTEMROLEAPPUSER.SECURITYMODECODE = 0)
      or (
        exists(
          select 1
          from dbo.SITEPERMISSION
          where SITEID = @SITEID
          and APPUSERID = SYSTEMROLEAPPUSER.APPUSERID
          and SYSTEMROLEID = SYSTEMROLEAPPUSER.SYSTEMROLEID
        )
        and (SYSTEMROLEAPPUSER.SECURITYMODECODE = 2 or SYSTEMROLEAPPUSER.SECURITYMODECODE = 3)
      )
      or (SYSTEMROLEAPPUSER.SECURITYMODECODE = 1 and @SITEID is null)
    )
  )
    return 1;

  return 0;
end