Monday, February 9, 2026

rls

To enable row-level security (RLS) in MS SQL Server (2016 and later), you need to define a security policy that uses a user-defined, inline table-valued function as a filter predicate.

Step-by-Step Guide

1. Ensure compatibility

Verify that your SQL Server instance is at least SQL Server 2016 or newer.

2. Create a schema for RLS objects (Recommended)

This practice separates your security logic from the application data.

CREATE SCHEMA Security;
GO

3. Create a predicate function

This inline table-valued function contains the logic for determining which rows a user can access. The function must be created with SCHEMABINDING.

Example: This function allows a user to see rows where the UserID column matches their username, or if they are a Manager.

CREATE FUNCTION Security.fn_securitypredicate(@UserID AS sysname)
    RETURNS TABLE
    WITH SCHEMABINDING
AS
    RETURN SELECT 1 AS result
    WHERE @UserID = USER_NAME() OR USER_NAME() = 'Manager';
GO

4. Create and enable a security policy

The security policy links the predicate function to your target table and enables the RLS enforcement.

Example: This policy applies the function to the dbo.YourTable table, using the UserID column for the filter.

CREATE SECURITY POLICY SecurityPolicy
ADD FILTER PREDICATE Security.fn_securitypredicate(UserID) ON dbo.YourTable
WITH (STATE = ON);
GO

5. Grant necessary permissions

Ensure users have SELECT permission on both the target table and the security function.

GRANT SELECT ON dbo.YourTable TO SalesRep1;
GRANT SELECT ON Security.fn_securitypredicate TO SalesRep1;
-- Repeat for other users/roles as needed


Testing the Implementation
You can test RLS by impersonating different users to verify they only see authorized data.
sql
EXECUTE AS USER = 'SalesRep1';
SELECT * FROM dbo.YourTable; -- This will only show rows matching SalesRep1's UserID

REVERT; -- Stop impersonating
EXECUTE AS USER = 'Manager';
SELECT * FROM dbo.YourTable; -- This will show all rows
REVERT

Sunday, February 8, 2026

Docker run for mac

 docker run -d -p 10000:3000 -p 11000:4000  --name ub-react -v "/Users/atharvachandras/Desktop/rajesh/DockerVolumes/React:/rajesh" ubuntu:latest tail -F /dev/null


you have to use /Users/username/Desktop as base path

/Users/username has to be used, and it is always better to use /Desktop so that it is immediately visible ( otherwise everytime you have to use search option) 


docker run -d -p 10001:3001 -p 11001:4001  --name ub-python -v "/Users/atharvachandras/Desktop/rajesh/DockerVolumes/Python:/rajesh" ubuntu:latest tail -F /dev/null



docker exec -it ub-react bash

apt-get update 

apt-get install git

apt-get install vim


/* do NOT directly run following commands, they will get older versions */

apt-get install nodejs

apt-get install npm


/* instead use following commands  */

apt-get install -y curl

apt-get install sudo

curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -

sudo apt-get install -y nodejs




nodejs -v 

npm -v 


as of 08feb2026 : 24.13.0 and 11.6.2

Friday, March 21, 2025

Vercel Mongo Integration

 

A screenshot of a computer

AI-generated content may be incorrect.

 

 

A screenshot of a computer

AI-generated content may be incorrect.

 

 

 

 

Click continue

 

A screenshot of a computer

AI-generated content may be incorrect.

Press “I Acknowledge”

 

A screenshot of a computer

AI-generated content may be incorrect.

Multiselect vercel projects

Click “ “Connect and Return to  Vercel”

 

A screenshot of a computer

AI-generated content may be incorrect.

 

 

Takes a long time to complete  approx. 5 minutes

 

A screenshot of a computer

AI-generated content may be incorrect.

rls

To enable row-level security (RLS) in MS SQL Server (2016 and later) , you need to define a security policy that uses a user-defined, inli...