johnw65's avatar

How to Connect and Login as an Oracle User

I'm new to Laravel, and is currently using Laravel 7.

Immediately after a successful user login, how can I immediately connect/reconnect as an actual Oracle User rather than as a web application user then execute DBMS_Session.Set_Role('ALL') which will grant the current user all roles.

It's a requirement and also want to be able to keep an audit trail on each Oracle users until the user logs out. The audit must be performed at the database level. Thanks in advance.

0 likes
2 replies
prasadchinwal5's avatar
Level 35

@johnw65 I am assuming you are using Yajra OCI-8 driver Link

Why not try running these as raw queries.

DB::connection('oracle_connection_name')->raw('DBMS_Session.Set_Role('ALL')');

Not tried. But worth a shot.

johnw65's avatar

I'm using the Yajra OCI-8 driver, your script did work.

DB::connection('oracle')->raw('DBMS_Session.Set_Role('ALL')');

However, I want the system to connect as an actual Oracle database User so the system can have database level audit trail for each user.

Please or to participate in this conversation.