[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
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 /* $Id: class.postfixldap.inc.php 20199 2006-01-05 05:54:52Z lkneschke $ */ 13 14 include_once (EGW_SERVER_ROOT."/emailadmin/inc/class.defaultsmtp.inc.php"); 15 16 class postfixldap extends defaultsmtp 17 { 18 function addAccount($_hookValues) 19 { 20 $mailLocalAddress = $_hookValues['account_lid']."@".$this->profileData['defaultDomain']; 21 22 $ds = $GLOBALS['egw']->common->ldapConnect(); 23 24 $filter = "uid=".$_hookValues['account_lid']; 25 26 $sri = @ldap_search($ds,$GLOBALS['egw_info']['server']['ldap_context'],$filter); 27 if ($sri) 28 { 29 $allValues = ldap_get_entries($ds, $sri); 30 $accountDN = $allValues[0]['dn']; 31 $objectClasses = $allValues[0]['objectclass']; 32 33 unset($objectClasses['count']); 34 } 35 else 36 { 37 return false; 38 } 39 40 if(!in_array('qmailUser',$objectClasses) && 41 !in_array('qmailuser',$objectClasses)) 42 { 43 $objectClasses[] = 'qmailuser'; 44 } 45 46 // the new code for postfix+cyrus+ldap 47 $newData = array 48 ( 49 'mail' => $mailLocalAddress, 50 'accountStatus' => 'active', 51 'objectclass' => $objectClasses 52 ); 53 54 ldap_mod_replace ($ds, $accountDN, $newData); 55 #print ldap_error($ds); 56 } 57 58 function getAccountEmailAddress($_accountName) 59 { 60 $emailAddresses = array(); 61 $ds = $GLOBALS['egw']->common->ldapConnect(); 62 $filter = sprintf("(&(uid=%s)(objectclass=posixAccount))",$_accountName); 63 $attributes = array('dn','mail','mailAlternateAddress'); 64 $sri = @ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $attributes); 65 66 if ($sri) 67 { 68 $allValues = ldap_get_entries($ds, $sri); 69 if(isset($allValues[0]['mail'][0])) 70 { 71 $emailAddresses[] = array 72 ( 73 'name' => $GLOBALS['egw_info']['user']['fullname'], 74 'address' => $allValues[0]['mail'][0], 75 'type' => 'default' 76 ); 77 } 78 if($allValues[0]['mailalternateaddress']['count'] > 0) 79 { 80 $count = $allValues[0]['mailalternateaddress']['count']; 81 for($i=0; $i < $count; $i++) 82 { 83 $emailAddresses[] = array 84 ( 85 'name' => $GLOBALS['egw_info']['user']['fullname'], 86 'address' => $allValues[0]['mailalternateaddress'][$i], 87 'type' => 'alternate' 88 ); 89 } 90 } 91 } 92 93 return $emailAddresses; 94 } 95 96 function saveSMTPForwarding($_accountID, $_forwardingAddress, $_keepLocalCopy) 97 { 98 $ds = $GLOBALS['egw']->common->ldapConnect(); 99 $filter = sprintf("(&(uidnumber=%s)(objectclass=posixAccount))",$_accountID); 100 $attributes = array('dn','mailforwardingaddress','deliverymode','objectclass'); 101 $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $attributes); 102 103 if ($sri) 104 { 105 $newData = array(); 106 $allValues = ldap_get_entries($ds, $sri); 107 108 $newData['objectclass'] = $allValues[0]['objectclass']; 109 110 unset($newData['objectclass']['count']); 111 112 if(!in_array('qmailUser',$newData['objectclass']) && 113 !in_array('qmailuser',$newData['objectclass'])) 114 { 115 $newData['objectclass'][] = 'qmailuser'; 116 } 117 118 if(!empty($_forwardingAddress)) 119 { 120 if(is_array($allValues[0]['mailforwardingaddress'])) 121 { 122 $newData['mailforwardingaddress'] = $allValues[0]['mailforwardingaddress']; 123 unset($newData['mailforwardingaddress']['count']); 124 $newData['mailforwardingaddress'][0] = $_forwardingAddress; 125 } 126 else 127 { 128 $newData['mailforwardingaddress'][0] = $_forwardingAddress; 129 } 130 $newData['deliverymode'] = ($_keepLocalCopy == 'yes'? array() : 'forwardOnly'); 131 } 132 else 133 { 134 $newData['mailforwardingaddress'] = array(); 135 $newData['deliverymode'] = array(); 136 } 137 138 ldap_modify ($ds, $allValues[0]['dn'], $newData); 139 #print ldap_error($ds); 140 } 141 } 142 } 143 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |