Hi,
connecting to oracle may either be a local connection (oracle client and server on the 
same machine) or over the network (using sqlnet/net8). With dbi, i did not yet succeed 
in creating a local session, dbi seems to always connect via sqlnet/net8, even if the 
perl script is executed on the same machine where the database runs. The only way to 
do what you want is to use the remote authentication feature, which is unrecommended 
because it is unsecure. Set the following parameters in init<SID>.ora:

        os_authent_prefix = "ops$"
        remote_os_authent= true 

now create a database user with the same name as the unix-user the database belongs 
to, e.g. oracle, prefixed by "ops$" and using os-authentication, i.e.

        create user ops$oracle identified externally;
        grant create session to ops$oracle;

now you can open a database connection with a script like

        #!/opt/perl5/bin/perl -w
        use strict;
        use DBI;
        my $dbname="host=<hostname>;sid=<SID>;port=<port>";
        my $dbh = DBI->connect("DBI:Oracle:$dbname",'/','')
                        || die "Unable to connect to $dbname $DBI::errstr\n";
        my $sth = $dbh->prepare("select 'connected to oracle' from dual");
        $sth->execute();
        my $status = $sth->fetchrow_array;
        print "$status \n";

Connection to the database works from any host on the network where a unix user with 
the same name (oracle in this example) exists! I don't know if that is what you want.
BTW: remote connections over the network with os authentication only works with prefix 
"ops$". Any other prefix, including "", will not work.

Stefan

-----Urspr�ngliche Nachricht-----
Von: Thomson Bob [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 9. Juli 2003 18:31
An: '[EMAIL PROTECTED]'
Betreff: DBD:Oracle connected without user and password.


In the otherwise excellent documentation at :

http://search.cpan.org/author/TIMB/DBD-Oracle-1.14/Oracle.pm#Connection_Exam
ples_Using_DBD_Oracle

It's not too clear how to connect to a local database with a user which has
been set-up to
authenticate via the OS (alter user USERNAME identified externally)

i.e. Thinking, as I did, that you can do :

my $dbh = DBI->connect('DBI:Oracle:SID','/');

and getting this kind of the error :

ORA-01004: default username feature not supported; logon denied (DBD ERROR:
OCISessionBegin)

I think an explicit example like this would help :

my $dbh = DBI->connect('DBI:Oracle:','/');


Bob Thomson,
UNIX Team,
Newell and Budge,
North Lanarkshire Council.


Mail : [EMAIL PROTECTED]




*********************************************************************
North Lanarkshire Council's Web Site
 http://www.northlan.gov.uk/
*********************************************************************
This e-mail and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they
are addressed.  If you have received this e-mail in error, please 
notify the System Manager and thereafter delete the e-mail from 
your system.  The System Manager may be contacted at 
[EMAIL PROTECTED] or by telephone on 01698 302254.
E-mail transmission is not secure and information can be intercepted, 
corrupted, lost, destroyed, delayed or incomplete.  The sender does
not accept any liability for errors or omissions arising as a result
of e-mail transmission or interception.  Please note that incoming
e-mails are routinely scanned for the purpose of detecting offensive
or inappropriate materials.

**********************************************************************

Reply via email to