USP_DATALIST_APPLICATIONUSERSYSTEMROLES

Returns a list of all system roles in which the given user is a member.

Parameters

Parameter Parameter Type Mode Description
@APPUSERID uniqueidentifier IN Input parameter indicating the context ID for the data list.

Definition

Copy


                CREATE procedure dbo.USP_DATALIST_APPLICATIONUSERSYSTEMROLES (@APPUSERID uniqueidentifier)
                as
                    --Used by the "Application User System Roles" datalist

                    --Returns the system roles in which the given user is a member


                    select  
                        SYSTEMROLE.ID, 
                        SYSTEMROLE.NAME,
                        SYSTEMROLE.DESCRIPTION, 
                        SYSTEMROLEAPPUSER.FROMROLESYNC,
                        SYSTEMROLEAPPUSER.ID as SYSTEMROLEAPPUSERID,
                        case SYSTEMROLEAPPUSER.SECURITYMODECODE
                        when 2 then
                            (select 
                                dbo.UDA_BUILDLIST(SITE.NAME) 
                            FROM 
                                dbo.SITE 
                                inner join dbo.SYSTEMROLEAPPUSERSITE ON SYSTEMROLEAPPUSERSITE.SITEID = SITE.ID
                            where
                                SYSTEMROLEAPPUSERSITE.SYSTEMROLEAPPUSERID = SYSTEMROLEAPPUSER.ID
                            )
                        when 3 then
                            'Records within the ' + (select SITE.NAME from dbo.SITE where SITE.ID = SYSTEMROLEAPPUSER.BRANCHSITEID) + ' branch'
                        else
                            SYSTEMROLEAPPUSER.SECURITYMODE
                        end as SITESECURITY,
                        case SYSTEMROLEAPPUSER.CONSTITUENTSECURITYMODECODE
                        when 2 then
                            (select
                                dbo.UDA_BUILDLIST(CONSTIT_SECURITY_ATTRIBUTE.NAME)
                            from
                                dbo.CONSTIT_SECURITY_ATTRIBUTE
                                inner join dbo.SYSTEMROLEAPPUSERCONSTITUENTSECURITY on SYSTEMROLEAPPUSERCONSTITUENTSECURITY.CONSTITUENTSECURITYATTRIBUTEID = CONSTIT_SECURITY_ATTRIBUTE.ID
                            where    
                                SYSTEMROLEAPPUSERCONSTITUENTSECURITY.SYSTEMROLEAPPUSERID = SYSTEMROLEAPPUSER.ID
                            )
                        else
                            SYSTEMROLEAPPUSER.CONSTITUENTSECURITYMODE
                        end as CONSTITUENTSECURITY                        
                    from 
                        dbo.SYSTEMROLE 
                        inner join dbo.SYSTEMROLEAPPUSER on SYSTEMROLE.ID = SYSTEMROLEAPPUSER.SYSTEMROLEID
                    where 
                        SYSTEMROLEAPPUSER.APPUSERID = @APPUSERID                    
                    order by 
                        SYSTEMROLE.NAME ASC