/** * Establishes a working connection * * @return Net_LDAP2 */ public function &connect() { // Check extension if (true !== Net_LDAP2::checkLDAPExtension()) { $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); } // Simple working connect and privilegued bind $lcfg = array('host' => $this->ldapcfg['global']['server_address'], 'port' => $this->ldapcfg['global']['server_port'], 'basedn' => $this->ldapcfg['global']['server_base_dn'], 'binddn' => $this->ldapcfg['global']['server_binddn'], 'bindpw' => $this->ldapcfg['global']['server_bindpw'], 'filter' => '(ou=*)'); $ldap = Net_LDAP2::connect($lcfg); $this->assertInstanceOf('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check credentials and host address. If those are correct, file a bug!'); return $ldap; }
/** * testStartTLS() if server supports it */ public function testStartTLS() { // Check extension if (true !== Net_LDAP2::checkLDAPExtension()) { $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); } if (!$this->ldapcfg) { $this->markTestSkipped('No ldapconfig.ini found. Skipping test!'); } elseif ($this->ldapcfg['global']['server_cap_tls'] == true) { // Simple working connect and privilegued bind $lcfg = array('host' => $this->ldapcfg['global']['server_address'], 'port' => $this->ldapcfg['global']['server_port'], 'binddn' => $this->ldapcfg['global']['server_binddn'] . ',' . $this->ldapcfg['global']['server_binddn'], 'bindpw' => $this->ldapcfg['global']['server_bindpw'], 'starttls' => true); $ldap = Net_LDAP2::connect(); $this->assertInstanceOf('Net_LDAP2', $ldap, 'Connect failed but was supposed to work. Check credentials and host address. If those are correct, file a bug!'); } else { $this->markTestSkipped('Server does not support TLS (see ldapconfig.ini). Skipping test.'); } }