note 111614 added to function.oci-connect
| From: | blake dot lewis at gmail dot com | Date: | Fri, 08 Mar 2013 15:10:05 +0000 |
| Subject: | note 111614 added to function.oci-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193995@lists.php.net to get a copy of this message | ||
Using ldap for Oracle name resolution:
The web server will need the environmental variable TNS_ADMIN='Directory of tnsname.ora'
unless the default location is used. I use '/etc/tns_admin'. Confirm using the phpinfo().
There are three files needed in the TNS_ADMIN location: tnsnames.ora, sqlnet.ora and ldap.ora. If
you are only using ldap, tnsnames.ora is not needed.
To sqlnet.ora add:
NAMES.DIRECTORY_PATH=(TNSNAMES,LDAP)
To ldap.ora add:
DIRECTORY_SERVERS=(ldap_server_fqdn:port)
DEFAULT_ADMIN_CONTEXT=""
DIRECTORY_SERVER_TYPE=OID
For a quick and dirty ldap tnsnames server use tnsManager by Dave Berry. Oracle OID or Openldap
can used, but are complicated to setup. tnsManager is a no brainer. The quick part: give it a
tnsnames.ora file and start it up. The dirty parts: I can't get Toad and SQLDeveloper to work
with it, it ignores the domain and it is no longer being maintained.
The order of values in NAMES.DIRECTORY_PATH in sqlnet.ora determines which look up
'adapter' is used, in this case it is tnsnames.ora file and then ldap. I use ldap for
general consumption and tnsnames.ora file to override ldap or entries that are not for general
consumption.
If you have the full Oracle client you have tnsping. 'tnsping ORACLE_SID' will tell you
what adapter you are using: 'Used LDAP adapter to resolve the alias'.
<?php
echo system("/PATH/tnsping ".$ORACLE_SID." 2>&1")."<br
/>";
echo 'TNS_ADMIN='.getenv('TNS_ADMIN');
?>
ISSUE:
If connecting with only ORACLE_SID and not ORACLE_SID.DB_DOMAIN, the value of NAMES.DEFAULT_DOMAIN
from sqlnet.ora is appended, then for some reason PHP tries the HOSTNAME adapter, and if the
database name resolves in DNS, it will fail connecting using the database name as the hostname,
because neither SID nor SERVICE_NAME are defined.
If using tnsManager append '.ANY_DOMAIN' to $ORACLE_SID to hack around the issue above.
I have tested with:
11.1.0.7 full client and PHP 5.1.6
11.2.0.2 full client and PHP 5.4.11
I have heard that LDAP lookup does not work with older instantclients.
----
Server IP: 69.147.83.199
Probable Submitter: 128.206.184.173
----
Manual Page -- http://php.net/manual/en/function.oci-connect.php
Edit -- https://master.php.net/note/edit/111614
Del: integrated -- https://master.php.net/note/delete/111614/integrated
Del: useless -- https://master.php.net/note/delete/111614/useless
Del: bad code -- https://master.php.net/note/delete/111614/bad+code
Del: spam -- https://master.php.net/note/delete/111614/spam
Del: non-english -- https://master.php.net/note/delete/111614/non-english
Del: in docs -- https://master.php.net/note/delete/111614/in+docs
Del: other reasons-- https://master.php.net/note/delete/111614
Reject -- https://master.php.net/note/reject/111614
Search -- https://master.php.net/manage/user-notes.php