The main issue is that I want to audit user behavior (with triggers), but we are currently using connection pooling with our database, so don't have their username/id directly inside the db.

  1. I understand that there is an EXECUTE AS LOGIN function in MSSQL Server. Is there something similar in MySQL or Postgres?

  2. Do I have other options, other than auditing from the ORM and not the database?

Thanks!

有帮助吗?

解决方案

In PostgreSQL you can use SET ROLE or SET SESSION AUTHORIZATION but you must have the role already defined in the database.

You can choose which of them fits better your needs.

其他提示

In addition to SET ROLE there is another possibly useful option SET APPLICATION_NAME. This doesn't have to be the application - as long as your app's usernames fit in 64 characters it's very useful for that.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top