UFN_SITEID_MAPFROM_APPUSERID
Return
Return Type |
---|
table |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@APPUSERID | uniqueidentifier | IN |
Definition
Copy
create function dbo.UFN_SITEID_MAPFROM_APPUSERID
(
@APPUSERID uniqueidentifier
)
returns @SITES table (SITEID uniqueidentifier)
as
begin
/*Return all sites if the application user is a system administrator or is assigned to a role with access to all sites*/
if dbo.UFN_APPUSER_ISSYSADMIN(@APPUSERID) = 1 or exists(SELECT SYSTEMROLEAPPUSER.ID from dbo.SYSTEMROLEAPPUSER where SYSTEMROLEAPPUSER.APPUSERID = @APPUSERID and SYSTEMROLEAPPUSER.SECURITYMODECODE = 0) begin
insert into @SITES(SITEID)
select SITE.ID from dbo.SITE
union all
select null;
return;
end
insert into @SITES(SITEID)
select distinct
SITEID
from
dbo.SITEPERMISSION
where
SITEPERMISSION.APPUSERID = @APPUSERID;
--Return the null site if the application user has access to the no site.
if exists(SELECT 1 from dbo.SYSTEMROLEAPPUSER where SYSTEMROLEAPPUSER.APPUSERID = @APPUSERID and SYSTEMROLEAPPUSER.SECURITYMODECODE = 1)
insert into @SITES(SITEID) select null;
--Return the null site if sites are not installed in the system at all.
if dbo.UFN_INSTALLEDPRODUCTS_PRODUCTIS('133F9BCA-00F1-4007-9792-586B931340C6') = 0
insert into @SITES(SITEID) select null;
return;
end