/** * @expectedException \Piwik\Exception\ErrorException * @expectedExceptionMessage triggered error */ public function test_bind_ThrowsPhpErrors() { $this->setPiwikErrorHandling(); $this->addLdapMethodThatTriggersPhpError('ldap_bind'); $ldapClient = new LdapClient(); $ldapClient->bind("resource", "password"); }
/** * Public only for use in closure. */ public function bindAsAdmin(LdapClient $ldapClient, ServerInfo $server) { $adminUserName = $server->getAdminUsername(); // bind using the admin user which has at least read access to LDAP users if (!$ldapClient->bind($adminUserName, $server->getAdminPassword())) { throw new Exception("Could not bind as LDAP admin."); } }