UFN_PROXYUSER_CHECKROLESANDPERMISSIONS

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@APPUSERID uniqueidentifier IN
@SITES xml IN
@SYSTEMROLEID uniqueidentifier IN
@SECURITYMODECODE tinyint IN
@BRANCHSITEID uniqueidentifier IN
@CONSTITUENTSECURITYMODECODE tinyint IN
@CONSTITUENTSECURITYGROUPS xml IN

Definition

Copy


                CREATE function dbo.UFN_PROXYUSER_CHECKROLESANDPERMISSIONS(@APPUSERID uniqueidentifier,@SITES xml,
                @SYSTEMROLEID uniqueidentifier,@SECURITYMODECODE tinyint, @BRANCHSITEID uniqueidentifier, @CONSTITUENTSECURITYMODECODE tinyint, @CONSTITUENTSECURITYGROUPS xml)
                returns bit
                with execute as caller
                as begin
                        declare @ISPROXYUSERHASPERMISSION bit = 0;
                        declare @PROXYOWNERID uniqueidentifier = null;
                        declare @PROXYUSERROLES nvarchar(max) = null;
                        declare @PROXYUSERROLESCOUNT int = 0

                        select @PROXYOWNERID = PROXYOWNERID from dbo.APPUSER where ID = @APPUSERID;

                        --Check if Proxy owner has same role

                        -- If systemrole does not exist for proxy owner or site security or constituent security settings doesn't matched

                        -- below if condition or site security/constituent security function returns 0. if any one function returns then 

                        -- we will stop user by saving the record.

                        if((select count(1) from SYSTEMROLEAPPUSER where SYSTEMROLEID = @SYSTEMROLEID and APPUSERID = @PROXYOWNERID)=0)
                            return 0;

                        --Check Site security


                        If dbo.UFN_PROXYUSER_CHECKSITESECURITYRIGHTS(@APPUSERID, @SITES,@SYSTEMROLEID, @SECURITYMODECODE, @BRANCHSITEID, @PROXYOWNERID) = 0
                            return 0

                        --Check Constituent Security


                        If dbo.UFN_PROXYUSER_CHECKCONSTITUENTSECURITYRIGHTS(@APPUSERID, @SYSTEMROLEID, @CONSTITUENTSECURITYMODECODE ,@CONSTITUENTSECURITYGROUPS, @PROXYOWNERID) = 0
                            return 0;

                    return 1;
                end