Christian Merz wrote:
> this topic has been discussed several times, i know. But i have not
> seen a solution by now.
>
> On UNIX i can open an Oracle DB "connect internal" connection by
> $ sqlplus "/ as sysdba"
> when i am in OS group 'dba' - there is no need to specify a password.
>
> Whichever type of connection i use with DBI i HAVE TO specify a
> password. But i certainly do not want to code my sys/system passwords
> in my skripts.
>
> Any short slution on this?
FWIW it _appears_ to work on Windows, at least, unless I've done something
silly?
#!perl -w
use strict;
use DBI;
use DBD::Oracle qw/:ora_session_modes/;
my $dbh = DBI->connect('dbi:Oracle:',
shift||'',
shift||'',
{
RaiseError => 1,
AutoCommit => 0,
ora_session_mode => ORA_SYSDBA,
})
or die DBI->errstr;
print $dbh->selectrow_array('select instance_name from v$instance') . "\n";
print $dbh->selectrow_array('select user from dual') . "\n";
$dbh->disconnect;
__END__
ActiveState Perl 5.8.0, DBD-Oracle 1.14 + a couple of minor patches (nothing
to do with OS auth though), DBI 1.37.
Windows 2000, Oracle 9.2.0.3, user is a member of the ORA_DBA group and OS
authentication temporarily turned on for this test.
Running this with a few different parameters gives:
[EMAIL PROTECTED] /cygdrive/h/temp
$ perl os_auth_test.pl
dev92
SYS
[EMAIL PROTECTED] /cygdrive/h/temp
$ perl os_auth_test.pl darth vader
dev92
SYS
[EMAIL PROTECTED] /cygdrive/h/temp
$ perl os_auth_test.pl darth
DBI connect('','darth',...) failed: ORA-01005: null password given; logon
denied (DBD ERROR: OCISessionBegin) at os_auth_test.pl line 6
Which seems to show it works... but if you specify a username you have to at
least put some nonsense in for the password.
Also works if I put the database name into the DSN, i.e. 'dbi:Oracle:dev92'.
(Haven't got around to putting Oracle on the Linux partition yet though, and
haven't got access to a Unix environment with Oracle until next week; so
milage may vary on Unix)
--
Andy Hassall ([EMAIL PROTECTED]) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)