I just can't get this to bind when I put it on the live server. However, I have been very successful connecting to the ldap server when running my code on my local server using MAMP. Can anyone tell me what could be going wrong? I know I am using OpenLdap if that helps. Here is my code:

Of course I substituted the domain name and the username/password for fake ones on this post, but its in the same format I'm using.

// specify the LDAP server to connect to
$conn = ldap_connect('webmail.example.com', 389) or die("Could not connect to server");

ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3);

// bind to the LDAP server specified above 
$r = ldap_bind($conn, 'username', 'password') or die("Could not bind to server: ".ldap_err2str($conn));

$result = ldap_search($conn, "fn=Contacts,fn=public,fn=ContactRoot", $query) or die ("Error in search query");
Here is the error I keep getting when i try to run this script on my live server:

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Can't contact LDAP server in /var/www/vhosts/xxxxxxxxxxxxxx/ldap_sample.php on line 27
Could not bind to server: Protocol error