Results 1 to 3 of 3

Thread: Authenticated users with zimbra server

  1. #1
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    1

    Default Authenticated users with zimbra server

    Hi,

    Is there any possibilities that i get a email and password that i have in zimbra from user and if they was valid let him use service ?
    i mean i want to use zimbra as a source for user authentication that all visitors that have zimbra account with us can use other services too


    Thank you

  2. #2
    Join Date
    Feb 2012
    Posts
    81
    Rep Power
    3

    Default

    Quote Originally Posted by djnemo View Post
    Hi,

    Is there any possibilities that i get a email and password that i have in zimbra from user and if they was valid let him use service ?
    i mean i want to use zimbra as a source for user authentication that all visitors that have zimbra account with us can use other services too
    Already considered authenticating against Zimbra's LDAP ?

  3. #3
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    1

    Default

    By this code you have ask users for email and password via a html form and pass to this php file and it will check username and password on server if valid then it will open them zimbra mailbox
    ATTENTION: If you will host this .php file on another server than zimbra server make sure than time is exactly the same

    PHP Code:

    <?php
        $user
    $_REQUEST['username'];
        
    $passwd$_REQUEST['password'];

        if(!
    $user)
        {
            echo 
    "No corrent way...!";
            return -
    2;
        }
        
    //
        //    Authenticate againest Active Directory
        //
            
    $domain                       substr(strrchr($user"@"), 1);
            
    $usernamestrstr($user'@'TRUE);
            
            
    $ldap['user']              = $username;
            
    $ldap['pass']              = $passwd;
            
    $ldap['host']              = 'zimbra.domain.net'
            
    $ldap['port']              = 389
            
    $ldap['dn']                = 'uid='.$ldap['user'].',ou=people,dc=domain,dc=net'
            
    $ldap['base']              = ''

            
    // connecting to ldap 
            
    $ldap['conn'] = ldap_connect$ldap['host'], $ldap['port'] ); 
            
    ldap_set_option($ldap['conn'], LDAP_OPT_PROTOCOL_VERSION3); 
            echo 
    "Connected </BR>";
            
            
    // binding to ldap 
            
    $ldap['bind'] = ldap_bind$ldap['conn'], $ldap['dn'], $ldap['pass'] ); 

            if (
    $ldap['bind']) 
            { 
                echo 
    "Auth Done </BR>";
            }
            else
            {
                echo 
    "Retry... </BR>";
                return -
    1;
            }
        
    //
        //    END
        //
        
        
    $PREAUTH_KEY"YOUR_PREAUTH_KEY_GOES_HERE"//zimbra$zmprov ... prov> gdpak domain.com 
        
    $WEB_MAIL_PREAUTH_URL="https://zim.bra.ip.addr/service/preauth";    //Server address

        
    $email $user//email from HTML form


        
    if(empty($PREAUTH_KEY)) {
            die(
    "Need preauth key for domain ".$domain);
        }

        
    $timestamp=time()*1000//Web server and Zimbra server most be SAME time HH:MM:ss
        
    $preauthToken=hash_hmac("sha1",$email."|name|0|".$timestamp,$PREAUTH_KEY);
    //$preauthURL = $WEB_MAIL_PREAUTH_URL."?account=".$email."&by=name&timestamp=".$timestamp."&expires=0&preauth=".$preauthToken."&redirectURL=/zimbra/?cl$
        
    $preauthURL $WEB_MAIL_PREAUTH_URL."?account=".$email."&by=name&timestamp=".$timestamp."&expires=0&preauth=".$preauthToken;

        
    header("Location: $preauthURL");
    ?>

Similar Threads

  1. Replies: 3
    Last Post: 04-09-2010, 12:26 PM
  2. Local Authenticated Users regarded as Spam?
    By skaag in forum Administrators
    Replies: 3
    Last Post: 03-24-2010, 12:43 PM
  3. Replies: 7
    Last Post: 08-13-2008, 04:08 PM
  4. Replies: 39
    Last Post: 12-07-2007, 06:09 AM
  5. Replies: 2
    Last Post: 01-21-2006, 01:42 PM

Posting Permissions

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