Results 1 to 2 of 2

Thread: How to Use PHP LDAP on Zimbra

  1. #1
    peter76 is offline Active Member
    Join Date
    Apr 2008
    Posts
    30
    Rep Power
    7

    Wink How to Use PHP LDAP on Zimbra

    Can someone please help me? I don't know what I'm missing.

    ldapsearch works just fine:
    Code:
    ldapsearch -x -v -H 'ldap://hostname' -D 'uid=zimbra,cn=admins,cn=zimbra' -b "dc=com" "zimbraMailForwardingAddress=user@domain" mail -W | less
    I'm doing this in php:
    Code:
    $c = ldap_connect("hostname") or die("Peter cannot connect to LDAP server.");
    ldap_set_option($c, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($c, LDAP_OPT_REFERRALS, 0);
    ldap_start_tls($c);
    $bind = ldap_bind($c, $user, $pass);
    But I keep getting this error:
    Code:
    Mar 12 16:01:36 localhost httpd: PHP Warning:  ldap_start_tls() [<a href='function.ldap-start-tls'>function.ldap-start-tls</a>]: Unable to start TLS: Connect error in /var/www/html/ldap.php on line 14
    Mar 12 16:01:37 localhost httpd: PHP Warning:  ldap_bind() [<a href='function.ldap-bind'>function.ldap-bind</a>]: Unable to bind to server: Can't contact LDAP server in /var/www/html/ldap.php on line 15
    This is in /etc/openldap/ldap.conf:
    Code:
    TLS_CACERT      /etc/openldap/cacerts/ca.cer
    What am I missing? I've been banging my head against this brick wall for days. Thank you.

  2. #2
    sjangra's Avatar
    sjangra is offline Intermediate Member
    Join Date
    May 2011
    Posts
    24
    Rep Power
    4

    Thumbs up PHP Script to bind with Zimbra LDAP Server

    Hi Peter
    Here is PHP script to bind with Zimbra LDAP Server. Hope it will help you.
    ################################################
    <?php
    $ldap['pass'] = 'password';
    $ldap['host'] = 'zimbra-ldap.example.com'; //or you can put IP of ldap server
    $ldap['port'] = 389;
    $ldap['dn'] = 'uid=zimbra,cn=admins,cn=zimbra';
    // connecting to ldap
    $ldap['conn'] = ldap_connect( $ldap['host'], $ldap['port'] );
    ldap_set_option($ldap['conn'], LDAP_OPT_PROTOCOL_VERSION, 3);
    // binding to ldap
    $ldap['bind'] = ldap_bind( $ldap['conn'], $ldap['dn'], $ldap['pass'] );
    if ($ldap['bind']) {
    echo "LDAP bind successful...";
    } else {
    echo "LDAP bind failed...";
    }
    ?>
    ################################################
    Enjoy !!!
    Last edited by sjangra; 01-05-2012 at 11:41 PM. Reason: More Explained Answer
    Thanks & Regards
    S. Jangra
    System Admin

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Postfix unavailable - queue down
    By pmona in forum Administrators
    Replies: 20
    Last Post: 01-21-2010, 10:03 PM
  2. Replies: 15
    Last Post: 11-24-2009, 08:46 AM
  3. /tmp filling
    By Nutz in forum Administrators
    Replies: 8
    Last Post: 02-22-2008, 02:00 AM
  4. [SOLVED] Clamav problem ? What's happening ?
    By aNt1X in forum Installation
    Replies: 23
    Last Post: 02-14-2008, 05:43 AM
  5. Can't start Zimbra!
    By zibra in forum Administrators
    Replies: 5
    Last Post: 03-22-2007, 11:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •