xref: /PHP-5.6/ext/oci8/tests/drcp_privileged.phpt (revision 89e93bd2)
1--TEST--
2DRCP: privileged connect
3--SKIPIF--
4<?php
5if (!extension_loaded('oci8')) die("skip no oci8 extension");
6require(dirname(__FILE__)."/connect.inc");
7if (!$test_drcp) die("skip requires DRCP connection");
8if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
9ob_start();
10phpinfo(INFO_MODULES);
11$phpinfo = ob_get_clean();
12if (preg_match('/Compile-time ORACLE_HOME/', $phpinfo) !== 1) {
13    // Assume building PHP with an ORACLE_HOME means the tested DB is on the same machine as PHP
14    die("skip this test is unlikely to work with a remote database - unless an Oracle password file has been created");
15}
16
17preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv);
18// This test in Oracle 12c needs a non-CDB or the root container
19if (isset($matches_sv[0]) && $matches_sv[1] >= 12) {
20    $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual");
21    $r = @oci_execute($s);
22    if (!$r)
23        die('skip could not identify container type');
24    $r = oci_fetch_array($s);
25    if ($r['DBTYPE'] !== 'CDB$ROOT')
26        die('skip cannot run test using a PDB');
27}
28?>
29--INI--
30oci8.privileged_connect=1
31--FILE--
32<?php
33
34// Connecting as SYSDBA or SYSOPER through DRCP will give ORA-1031
35
36require dirname(__FILE__)."/details.inc";
37var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSDBA));
38var_dump(oci_connect($user,$password,$dbase,false,OCI_SYSOPER));
39var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSDBA));
40var_dump(oci_new_connect($user,$password,$dbase,false,OCI_SYSOPER));
41var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA));
42var_dump(oci_pconnect($user,$password,$dbase,false,OCI_SYSOPER));
43
44echo "Done\n";
45
46?>
47--EXPECTF--
48Warning: oci_connect(): ORA-01031: %s in %s on line %d
49bool(false)
50
51Warning: oci_connect(): ORA-01031: %s in %s on line %d
52bool(false)
53
54Warning: oci_new_connect(): ORA-01031: %s in %s on line %d
55bool(false)
56
57Warning: oci_new_connect(): ORA-01031: %s in %s on line %d
58bool(false)
59
60Warning: oci_pconnect(): ORA-01031: %s in %s on line %d
61bool(false)
62
63Warning: oci_pconnect(): ORA-01031: %s in %s on line %d
64bool(false)
65Done
66
67