note 27032 added to function.ocilogon
| From: | john at john-warner dot com | Date: | Wed, 20 Nov 2002 22:13:20 +0000 |
| Subject: | note 27032 added to function.ocilogon | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-39773@lists.php.net to get a copy of this message | ||
In addition to the earlier posts here is a further explaination;
Problem: Regular and Remote authentication does not work using Windows 2000 + PHP and Oracle 8i, 9i.
Secondary Issue if using Oracle 9.2.0.1
When using Oracle 9.2.0.1 the Error structure returned by Oracle is different than expected by
PHP. As a result there will be no legible error message other than the following;
Warning: _oci_open_server: in ...
Using Oracle 9.0.1.1 the error message returned is any of the following depending on your situation;
Warning: _oci_open_server: ORA-12638: Credential retrieval failed in ...
Warning: _oci_open_server: ORA-12154: TNS:could not resolve service name in ...
Warning: _oci_open_server: ORA-12505: TNS:listener could not resolve SID given in connect descriptor
in ...
Resolution:
In order to get this to work properly you need to do the following;
In reference to ORA-12638: Credential retrieval failed in ...
you need to edit your sqlnet.ora file and change the
SQLNET.AUTHENTICATION_SERVICES = (NTS) to
SQLNET.AUTHENTICATION_SERVICES = (NONE)
The reason is that using NTS validation on a Windows 2000 machine essentially means Kerberos.
Using (NONE) will tell oracle not to expect kerberos "Credentials" as a means of
validation. In turn it will use the oracle authentication for a database user.
In reference to ORA-12154 and ORA-12505 you need to do the following;
In your php code you are using to connect you need to copy the section in tnsnames.ora
into a variable.
For example;
<?php
putenv("ORACLE_SID=TESTDB");
//putenv("ORACLE_HOME=/oracle/ora90");
//putenv("TNS_ADMIN=/oracle/ora90/network/admin");
$username = "scott";
$passwd = "tiger";
$db="(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=yourTargetMachine)(PORT=1521)
)
)
(CONNECT_DATA=(SERVICE_NAME=TESTDB))
)";
$conn = OCILogon($username,$passwd,$db);
if (!$conn)
{
echo "Connection failed";
echo "Error Message: [" . OCIError($conn) . "]";
exit;
}
else
{
echo "Connected!";
}
...
?>
I left the ORACLE_HOME and TNS_ADMIN putenv lines commented out and your need for them depends on
which web server you are using. If you are using Apache, you may need both.
If you are using Microsoft IIS you may need ORACLE_HOME. Putting it in can't hurt and it
appears PHP may read them if they are there but either way you should be working at this
point.
Live long and prosper.
--
http://www.php.net/manual/en/function.ocilogon.php
http://master.php.net/manage/user-notes.php?action=edit+27032
http://master.php.net/manage/user-notes.php?action=delete+27032
http://master.php.net/manage/user-notes.php?action=reject+27032