-
We want to connect to Oracle from Perl/DBD using external authentication means. I am using the below line and it gives me the following error:
####################################
$dbh = DBI->connect("dbi:Oracle:host=10.0.0.26;SID=ORCL;", "\/");
DBI->connect(host=10.0.0.26;SID=ORCL;) failed: ORA-01004: default username feature not supported; logon denied (DBD ERROR: OCISessionBegin)
######################################
I have created an Oracle user who would be authenticated externally. When I say:
$ sqlplus /
it works fine. I am able to connect to the database using SQLPLUS. I want to be able to do the same thru. Perl/DBD as well. Any suggestions... or did someone try this method???
Is there any other mean to connect externally to Oracle from Perl/DBD???
Thanks in advance!
-
I'm at a different desk and don't have my books/bookmarks and haven't used the DBI in a while so don't remember it off the top of my head, but I'm not sure if you can connect to a database through dbi and expect os authentication to work. You will probably have to supply a username/password to the dbi connect for it to work.
-
Try following
$datasource = "DBI:Oracle:orcl";
$user = "yourusername";
$password = "yourpassword";
$dbh = DBI->connect("$datasource", "$user", "$password");
The above piece of code is running fine in client machine which has perl/dbd
to connect oracle in server box with orcl network service name.
I think this might be helpful.
-
SKMORA,
what you have suggested is right and I have been using the
same technique so far.
But, the client does not like the idea of hardcoding
the userID/password in the file and also they are against
the idea of encrypting. They just want to use
DB EXTERNAL AUTHETICATION.
For eg: If I say
$ sqlplus /@ORCL (instead of $sqlplus user/password)
I get connect to the database as the OS user (of course
I have a created a user in Oracle whose userID is exactly same as the OS User).
So, I was wondering if you or anyone has a suggestion
or a work around for this.....
-
hmmm, interesting question. i can't answer your original question (did you try username = "/" and password =""?) but i can give you my work-around methodology that i use for perl and SQL scripts.
i have one password file on every server for each user (could be a file of all users as well). i have one user per file (thus using "cat"). please note that this is not very sophisticated, but it got us away from updating multiple scripts each time we changed pw's and from having the password visible with the unix "ps" command.
below is a perl example:
$passwordfile = "/secretpath/secretfile";
$userpass = `cat ${passwordfile}`;
if ( $userpass =~ m!^(.*)/(.*)$! )
{
$username = $1;
$passwd = $2;
}
d.
-
I tried different combinations without any success.
Right now, we do keep the userID/Password in one of
our configuration files. But, this client is against this
idea and they want extenral authentication OR encrypt
the password in a file.
-
This has worked for me before:
my $drh = DBI->install_driver('Oracle');
my $dbh = $drh->connect('tns_alias','/','') || die "not connected";
where tns_alias is the alias you use when you type
sqlplus /@tns_alias
-
marist89,
What's the difference between your code and the code below.
This code doesn't work but, yours does.
Please help. Thanks in advance.
#############################
use DBI();
# Establish a connection
print "Connecting Oracle Database...\n";
$dbh = DBI->connect("dbi:Oracle:host=10.0.0.26;sid=ORCL", '/', '');
print "Connected to Oracle Database.\n";
#############################
-
I'm not really a Perl guru. Typically, you must supply the port number somewhere in the connect string as well. Any other Perl opinions out there?
-
marist89,
I have realized that both are the same.
I have removed host=10.0.0.26 and it becomes
the same as yours and it works perfectly fine.
Thanks for you time and patince.
So, we do have a way to connect to Oracle using
External Authentication. Cool....
Now, my next goal is to figure out a way to do this
using PhP. 'Cos web-based application connects
DB using Perl and also using Php.
Can anybody help me with PhP???
-
How about an easy way to get the ORACLE_HOME set using perl?
now when i use shell scripts i set the ORACLE_SID only and use oraenv to get the ORACLE_HOME? I don't want to updates scripts everytime i upgrade the database.
what would be comparable to using oraenv in perl (or how do you use oraenv to run in the same shell as the perl script)?
thx, d.