Re: Q: Become user

From: David R. Thrash <thrash_at_delphi.onramp.net>
Date: 1995/05/29
Message-ID: <3qd5bu$q73_at_news.onramp.net>#1/1


I think this is in the FAQ. In any case here's a script I've modified after I got it from the FAQ several years ago!

In comp.databases.oracle article <D9Arww.F2D_at_freenet.carleton.ca> you wrote:
>
>
> One possible solution exists is the book Oracle 7.0, Admin. and Manag., by
> M. Ault. The disk that comes with the book includes many scripts, including
> one that will temp change a users password, connect you as them and then set
> the password back to the original value. In general this book is a good
 value.
> I'm sure there are various ways of getting the source.
>
> Dave Boswell

Cann't comment on the book!!

  • begin dba_connect.sql ===== remark remark dba_connect.sql remark remark This SQL script allows any user with DBA privilege to connect to remark another user's account without a password. It prompts the user remark for the name of the user to connect to and does the rest. The remark password of the latter user does not change. remark

set echo off
set verify off
set pause off

remark
remark Prompt for name of user to connect remark

set termout on
prompt Connect to user: &&1;
set termout off
column new_user new_value _user noprint; select '&&1' new_user from dual;

remark

remark	Set the variable '_password' equal to the encrypted value of
remark	'temporary_dummy_password_' as a default if the password query
remark	returns no rows

remark
define _password = "EeLESY/E_e3=a_fQiM>+EIiUX";

remark
remark Get the encrypted password of the user (requires DBA privilege) remark check if requested user is in database and password != _password remark
whenever sqlerror exit;
declare
  x char(30);
begin
  select password
    into x
    from dba_users
   where username = upper('&&_user')
     and password != '&_password';
end;
/
whenever sqlerror continue

column password new_value _password noprint; select password
  from dba_users
 where username = upper('&&_user');

remark

remark	Change the password of the user to 'temporary_dummy_password_'
remark	(requires DBA privilege)

remark
grant connect to &&_user identified by temporary_dummy_password_;

remark
remark Connect to the user using the password 'temporary_dummy_password_' remark
connect &&_user/temporary_dummy_password_;

remark

remark	Reset the encrypted password using the undocumented VALUES keyword
remark	to GRANT

remark
grant connect to &&_user identified by values '&&_password';

remark
remark Clean up the tracks
remark
undefine &&1;
undefine _user;
undefine _password;
clear buffer columns;
set termout on;
set verify on
set pause off
set echo on
===== end dba_connect.sql =====

--
David R. Thrash
dthrash_at_tac-one.com             Compuserve:  76217,1304
http://www.tac-one.com/

Thrash & Company
9102 Garland Road, Suite 216
Dallas, Texas 75218
Voice: 214.327.1972             Facsimile: 214.327.3510
Received on Mon May 29 1995 - 00:00:00 CEST

Original text of this message