Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15694

How to fire trigger-like code when a login becomes a user of a database

$
0
0

Here's the scenario we want to achieve -

1) Login authenticates to SQL instance

2) Login becomes a user in the XYZ database

3) Some sort of code fires when a login becomes a user in the XYZ database - maybe it's for auditing purposes, or it could be for features unlocking in a web site, or it might be for license enforcement in software. The point is that we want to fire what effectively amounts to trigger code when a user account is activated in a database.

This isn't a logon trigger but it's roughly the same concept, just at the database-level scope. If we tried to do this in a logon trigger, then it would not detect later in a session when the user issued the "USE XYZ" statement. So basically we're trying to fire trigger-like code whenever a user account is used.

Any suggestions? Thank you!


Viewing all articles
Browse latest Browse all 15694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>