source: trunk/emailadmin/inc/class.postfixldap.inc.php @ 2

Revision 2, 2.9 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /***************************************************************************\
3        * EGroupWare - EMailAdmin                                                   *
4        * http://www.egroupware.org                                                 *
5        * Written by : Lars Kneschke [lkneschke@linux-at-work.de]                   *
6        * -------------------------------------------------                         *
7        * This program is free software; you can redistribute it and/or modify it   *
8        * under the terms of the GNU General Public License as published by the     *
9        * Free Software Foundation; either version 2 of the License, or (at your    *
10        * option) any later version.                                                *
11        \***************************************************************************/
12
13        include_once(PHPGW_SERVER_ROOT."/emailadmin/inc/class.defaultsmtp.inc.php");
14
15        class postfixldap extends defaultsmtp
16        {
17                function addAccount($_hookValues)
18                {
19                        $mailLocalAddress       = $_hookValues['account_lid']."@".$this->profileData['defaultDomain'];
20
21                        $ds = $GLOBALS['phpgw']->common->ldapConnect();
22                       
23                        $filter = "uid=".$_hookValues['account_lid'];
24
25                        $sri = @ldap_search($ds,$GLOBALS['phpgw_info']['server']['ldap_context'],$filter);
26                        if ($sri)
27                        {
28                                $allValues      = ldap_get_entries($ds, $sri);
29                                $accountDN      = $allValues[0]['dn'];
30                                $objectClasses  = $allValues[0]['objectclass'];
31                               
32                                unset($objectClasses['count']);
33                        }
34                        else
35                        {
36                                return false;
37                        }
38                       
39                        if(!in_array('qmailUser',$objectClasses) &&
40                                !in_array('qmailuser',$objectClasses))
41                        {
42                                $objectClasses[]        = 'qmailuser';
43                        }
44                       
45                        // the new code for postfix+cyrus+ldap
46                        $newData = array
47                        (
48                                'mail'                  => $mailLocalAddress,
49                                'accountStatus'         => 'active',
50                                'objectclass'           => $objectClasses
51                        );
52
53                        ldap_mod_replace ($ds, $accountDN, $newData);
54                        #print ldap_error($ds);
55                }
56
57                function getAccountEmailAddress($_accountName)
58                {
59                        $emailAddresses = array();
60                        $ds = $GLOBALS['phpgw']->common->ldapConnect();
61                        $filter         = sprintf("(&(uid=%s)(objectclass=posixAccount))",$_accountName);
62                        $attributes     = array('dn','mail','mailAlternateAddress');
63                        $sri = @ldap_search($ds, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $attributes);
64                       
65                        if ($sri)
66                        {
67                                $allValues = ldap_get_entries($ds, $sri);
68                                if(isset($allValues[0]['mail'][0]))
69                                {
70                                        $emailAddresses[] = array
71                                        (
72                                                'name'          => $GLOBALS['phpgw_info']['user']['fullname'],
73                                                'address'       => $allValues[0]['mail'][0],
74                                                'type'          => 'default'
75                                        );
76                                }
77                                if($allValues[0]['mailalternateaddress']['count'] > 0)
78                                {
79                                        $count = $allValues[0]['mailalternateaddress']['count'];
80                                        for($i=0; $i < $count; $i++)
81                                        {
82                                                $emailAddresses[] = array
83                                                (
84                                                        'name'          => $GLOBALS['phpgw_info']['user']['fullname'],
85                                                        'address'       => $allValues[0]['mailalternateaddress'][$i],
86                                                        'type'          => 'alternate'
87                                                );
88                                        }
89                                }
90                        }
91                       
92                        return $emailAddresses;
93                }
94        }
95?>
Note: See TracBrowser for help on using the repository browser.