4 Replies Latest reply on Jan 6, 2009 9:31 PM by 244142

    ORA-12546: TNS:permission denied

    478018
      I am trying to connect using the Instant Client (10.2.0.1) and PHP (5.1.1) on Linux (RH FC4). When I execute

      OCILogon('MYUSER', 'MYPASSWD', 'MYDB');

      I get this error:

      Warning: ocilogon() [function.ocilogon]: ociopen_server: ORA-12546: TNS:permission denied in /var/www/html/testoci.php on line 3
      ORA-12546: TNS:permission denied

      I know it is successfully reading my tnsnames.ora file (when I provide a bogus name, I get the "could not resolve the connect identifier specified" error), so permissions and path for tnsnames.ora is ok.

      I have also tried running my httpd as myself rather than as 'apache', but it makes no difference.

      I can access my db via sqlplus and via perl DBD::Oracle. So I can't figure what I'm doing wrong in my PHP config.

      Here's what I see in phpinfo():
      -----------------------------------------------------
      oci8
      OCI8 Support      enabled
      Revision      $Revision: 1.269.2.3 $
      Active Persistent Links      0
      Active Links      0
      Oracle Version      10.1
      Compile-time ORACLE_HOME      /usr/lib/oracle/10.2.0.1/client/lib
      Libraries Used      no value
      Temporary Lob support      enabled
      Collections support      enabled
      -----------------------------------------------------

      Any help would be greatly appreciated!

      Thanks,
      Dave.
        • 1. Re: ORA-12546: TNS:permission denied
          444950
          OCILogon('MYUSER', 'MYPASSWD', 'MYDB');
          This is probably going to sound dumb, and is just a guess, and probably wrong given how you specified your example line of code and indicate a knowledge of Perl, but are you sure you're using single-quotes when specifying your logon information? If you're using double-quotes and there's a special character (like "$") in the password, then PHP might be interpreting the string differently from how you think.

          When in doubt, single-quotes in PHP will always give the literal string that your specify.

          I only take the guess because I once replied to a guy on this very forum who had made the same mistake... other than that, I'm stumped.

          Hope that helps,

          ~Indigo
          • 2. Re: ORA-12546: TNS:permission denied
            478018
            I used single quotes, but thanks for the suggestion. I'm sure it is something dumb like that though.

            Dave.
            • 3. Re: ORA-12546: TNS:permission denied
              678386
              Hi,

              I had this very mistake. In fact, sqlplus in command line was working, and connecting to the db in php command line was working too. The error was happening only when the page was requested throw a browser.

              Here is how I solved it :
              In /var/log/messages I saw that SElinux was blocking connexions from the http daemon.
              I just executed the command
              setsebool -P httpd_can_network_connect 1
              so that apache would be authorized to connect the db and here it is :)
              • 4. Re: ORA-12546: TNS:permission denied
                244142
                this works for me:
                <?php

                $db = "(DESCRIPTION =
                (ADDRESS = (PROTOCOL = TCP)(HOST = landon)(PORT = 1521))
                (CONNECT_DATA =
                (SERVER = DEDICATED)
                (SERVICE_NAME = LMKGDN)
                )
                )";
                $conn = oci_connect("lmkiii", "xoxoxoxox", $db);

                BTW oci_pconnect looks in a cache of old connections for a match...that should save time
                I'd get NOTHING done if I left selinux enforcing

                I get SELINUX warnings when I am typing in an email under Fedora 9.

                Insane! I'd get nowhere!

                Glad you are off and running!

                Edited by: landonmkelsey on Jan 6, 2009 1:05 PM

                Look at this:

                Re: ORA-12560: TNS:protocol adapter error