note 111400 modified in function.oci-connect by danbrown

From: Date: Thu, 07 Mar 2013 17:18:30 +0000
Subject: note 111400 modified in function.oci-connect by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193981@lists.php.net to get a copy of this message
Using ldap for Oracle name resolution: The web server needs the environmental variable TNS_ADMIN='Directory of tnsname.ora'. I use '/etc/tns_admin'. Confirm using the phpinfo() function. 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_fqdn_hostname:1575) 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 default port is 1575. The order of values in NAMES.DIRECTORY_PATH from sqlnet.ora determines which look up 'adapter' is used first, 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: For some reason PHP tries the HOSTNAME adapter first, and if the database name resolves in DNS, it will try connecting using the database name as the hostname with no SID or SERVICE_NAME defined. All other Oracle clients I have used will not try the HOSTNAME adapter unless it is listed in NAMES.DIRECTORY_PATH. I have heard that LDAP look up does not work with older instantclients. --was-- Using ldap for Oracle name resolution: The web server needs the environmental variable TNS_ADMIN='Directory of tnsname.ora'. I use '/etc/tns_admin'. Confirm using the phpinfo() function. 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_fqdn_hostname:1575) 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 default port is 1575. The order of values in NAMES.DIRECTORY_PATH from sqlnet.ora determines which look up 'adapter' is used first, 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: For some reason PHP tries the HOSTNAME adapter first, and if the database name resolves in DNS, it will try connecting using the database name as the hostname with no SID or SERVICE_NAME defined. All other Oracle clients I have used will not try the HOSTNAME adapter unless it is listed in NAMES.DIRECTORY_PATH. I have heard that LDAP look up does not work with older instantclients. http://php.net/manual/en/function.oci-connect.php

« previous php.notes (#193981) next »