I suggest you use Softtera Ldap software to test connections to Ldap before trying with the code. It will give you detailed error.