Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl connection to Oracle, without supplying a password ?

Status
Not open for further replies.

RogersJ

Technical User
Apr 23, 2003
11
US
I have a system requirement that I can't have hard coded userids and passwords.

I have a unix user, in the DBA group, that has an Oracle userid also, and is a SYSDBA.

Code:
#!/opt/perl/bin/perl
#

use Oraperl;

$lda = ora_login("my_database_name", "internal", " ", { ora_session_mode => 2 } ) or  die "$ora_errnum: $ora_errstr";

$csr1 = ora_open($lda, "select sysdate from dual") or die;

while (($data) = ora_fetch($csr1)) {
print $data;
}

ora_close($csr1);
ora_logoff($lda);

Produces the error:
ORA-01031: insufficient privileges (DBD ERROR: OCISessionBegin) at /oracle/perlsql line 6.

I have regenerated the password file in vain.

How do I get around providing a password ?

Oracle 8.0.6
HPUX11
Perl 5

Thanks for any suggestions.
 
OraPerl..... Haven't seen that in a while.

What about using an ordinary user, instead of internal, and specifying the password as normal?

Also.... Have you considered using The DBI instead or OraPerl? There's a compatability module (I think) for if you have a number of OraPerl scripts.

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Sript is now using DBI.

I get audited, and I am required not to have usernames and passwords specified in scripts.

I know that I could put a table in one of the databases containing the connect strings, userids and passwords, use a shell script to get the data then pass it to the perl script, but I'd rather not go that way.

Code:
#!/opt/perl/bin/perl
#

use DBI;

$lda = DBI->connect("dbi:Oracle:mydatabase", "scott", "tiger",{
        PrintError => 0, AutoCommit => 0 }) or  die "$ora_errnum: $ora_errstr";

@csr1 = $lda->selectrow_array( "select sysdate from dual") or die;

print @csr1,"\n";

$lda->disconnect;

Runs OK when you specify a valid userid and password
[mydatabase]/home/oger: perlsql
24-APR-03
[mydatabase]/home/oger:

==========================================
Result when you change to /
Code:
$lda = DBI->connect("dbi:Oracle:mydatabase", "/", "",{
ORA-01004: default username feature not supported; logon denied (DBD ERROR: OCISessionBegin) at ./perlsql line 6.

===========================================
Result indicating no password
Code:
$lda = DBI->connect("dbi:Oracle:mydatabase", "internal", "",{
ORA-01005: null password given; logon denied (DBD ERROR: OCISessionBegin) at ./perlsql line 6.

===========================================
Result using internal still the same.
Code:
$lda = DBI->connect("dbi:Oracle:mydatabase", "internal", " ",{
ORA-01031: insufficient privileges (DBD ERROR: OCISessionBegin) at ./perlsql line 6.


Regards
Jan Rogers
 
Resolution:

Code:
DBI->connect("dbi:Oracle:", '', '', { PrintError=>0, RaiseError =>0, ora_session_mode => 2} )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top