错误php连接OpenLDAP

i have in VirtualBox a Ubuntu Server with OpenLdap. I upload in this server in /var/www a form in php.

But i have this error:

HTTP 500 Internal server error

and the error come when the php try to connect to OpenLdap, the code is:

<?php

include('ldapmanagement.php');
session_start();

$myCheck = $_POST['myCheck'];



$ldaprdn  = 'cn=admin,dc=company,dc=com';     // ldap rdn or dn
$ldappass = 'secret';  // associated password
$LDAPHOST='ldaps://localhost';
$LDAPPORT=636;
$ldaptree = "OU=people,DC=company,DC=com"; //basedn
$filter =  "uid= $_SESSION[username]";


$connection = new Connection ($LDAPHOST,$LDAPPORT,$ldaprdn,$ldappass);
$connection->connect();
$data = $connection->search($ldaptree,$filter,$myCheck);
...
 ?>