Authentication using Zimbra LDAP and PHP

Zimbra Version

[[email protected] ~]$ zmcontrol -v
Release 8.8.15_GA_3829.RHEL6_64_20190718141144 RHEL6_64 FOSS edition, Patch 8.8.15_P1.

PHP Version

[[email protected] ~]# php -v
PHP 7.3.26 (cli) (built: Jan 5 2021 10:36:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.26, Copyright (c) 1998-2018 Zend Technologies

PHP Code

$ldap['user'] = 'emailuser';
$ldap['pass'] = 'emailuserpassword';
$ldap['host'] = '';
$ldap['port'] = 389;
$ldap['dn']   = 'uid='.$ldap['user'].',ou=people,dc=mailserver,dc=com';
$ldap['conn'] = ldap_connect( $ldap['host'], $ldap['port'] );
ldap_set_option($ldap['conn'], LDAP_OPT_PROTOCOL_VERSION, 3);
$ldap['bind'] = ldap_bind( $ldap['conn'], $ldap['dn'], $ldap['pass'] );
if ($ldap['bind']) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";


[[email protected] ~]# php zimbra.php
LDAP bind successful...
[[email protected] ~]#


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.