UDF's for column security

Database
Enthusiast

UDF's for column security

Anybody have a sample code snippet or a place I can find similar code. The code would mask the value of a column if it is not to be shown to userA but show it to userB (who have the security access to the column).
4 REPLIES
Fan

Re: UDF's for column security

Yes, I am interested in this too. If I am using a column level access in TD13, and a user is accessing a column for which it does not have access, is it possible to give a null/masked value rather throwing error?
Junior Supporter

Re: UDF's for column security

You can do it easily using views.

HTH.

Cheers.

Carlos.
Fan

Re: UDF's for column security

Sorry, I should have clear in my problem definition. In views we can mask, but that is only for all or nothing. Meaning if I had 10 users and i had 4 columns are masked, I want to do combination something like 2 users can see 1 column, vs another 4 can only see 3 of 4 and rest can see all the four.

Let me know if you need more detail example.

Thanks,
Enthusiast

Re: UDF's for column security

Something like this.

REPLACE VIEW DB.MaskView
AS LOCKING ROW FOR ACCESS
SELECT
Column1
,Column2
,CASE WHEN USER IN ('User1','User2') THEN '*********' ELSE Column3 END AS MaskedColumn
FROM Table1;

You can also use ROLE, or PROFILE so you can do some grouping of users as opposed to the big list. You'll just need to wrap similar case logic around everything you want to mask. Each one can have a distinct masking criteria.