[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/admin/inc/ -> class.soldap_mgr.inc.php (source)

   1  <?php
   2      /***************************************************************************\
   3      * EGroupWare - LDAPManager                                                  *
   4      * http://www.egroupware.org                                                 *
   5      * Written by : Andreas Krause (ak703@users.sourceforge.net                  *
   6      * based on EmailAdmin by Lars Kneschke [lkneschke@egroupware.org]           *
   7      * -------------------------------------------------                         *
   8      * This program is free software; you can redistribute it and/or modify it   *
   9      * under the terms of the GNU General Public License as published by the     *
  10      * Free Software Foundation; either version 2 of the License, or (at your    *
  11      * option) any later version.                                                *
  12      \***************************************************************************/
  13  
  14      class soldap_mgr
  15      {
  16  		function soldap_mgr()
  17          {
  18              $this->db = clone($GLOBALS['egw']->db);
  19              include (EGW_INCLUDE_ROOT.'/emailadmin/setup/tables_current.inc.php');
  20              $this->tables = &$phpgw_baseline;
  21              unset($phpgw_baseline);
  22              $this->table = &$this->tables['phpgw_emailadmin'];
  23          }
  24  
  25  		function getUserData($_accountID)
  26          {
  27              $ldap = $GLOBALS['egw']->common->ldapConnect();
  28              $filter = "(&(uidnumber=$_accountID))";
  29  
  30              $sri = @ldap_search($ldap,$GLOBALS['egw_info']['server']['ldap_context'],$filter);
  31              if ($sri)
  32              {
  33                  $allValues = ldap_get_entries($ldap, $sri);
  34                  if ($allValues['count'] > 0)
  35                  {
  36                      #print 'found something<br>';
  37                      $userData['mail']                    = $allValues[0]['mail'][0];
  38                      $userData['mailAlternateAddress']    = $allValues[0]['mailalternateaddress'];
  39                      $userData['accountStatus']            = $allValues[0]['accountstatus'][0];
  40                      $userData['mailForwardingAddress']    = $allValues[0]['mailforwardingaddress'][0];
  41                      $userData['deliveryMode']            = $allValues[0]['deliverymode'][0];
  42  
  43                      unset($userData['mailAlternateAddress']['count']);
  44                      unset($userData['mailForwardingAddress']['count']);
  45  
  46                      return $userData;
  47                  }
  48              }
  49  
  50              // if we did not return before, return false
  51              return false;
  52          }
  53  
  54  		function saveUserData($_accountID, $_accountData)
  55          {
  56              $ldap = $GLOBALS['egw']->common->ldapConnect();
  57              // need to be fixed
  58              if(is_numeric($_accountID))
  59              {
  60                  $filter = "uidnumber=$_accountID";
  61              }
  62              else
  63              {
  64                  $filter = "uid=$_accountID";
  65              }
  66  
  67              $sri = @ldap_search($ldap,$GLOBALS['egw_info']['server']['ldap_context'],$filter);
  68              if ($sri)
  69              {
  70                  $allValues         = ldap_get_entries($ldap, $sri);
  71                  $accountDN         = $allValues[0]['dn'];
  72                  $uid               = $allValues[0]['uid'][0];
  73                  $homedirectory    = $allValues[0]['homedirectory'][0];
  74                  $objectClasses    = $allValues[0]['objectclass'];
  75  
  76                  unset($objectClasses['count']);
  77              }
  78              else
  79              {
  80                  return false;
  81              }
  82  
  83              if(empty($homedirectory))
  84              {
  85                  $homedirectory = "/home/".$uid;
  86              }
  87  
  88              // the old code for qmail ldap
  89              $newData = array
  90              (
  91                  'mail'                    => $_accountData['mail'],
  92                  'mailAlternateAddress'    => $_accountData['mailAlternateAddress'],
  93                  'mailForwardingAddress'    => $_accountData['mailForwardingAddress'],
  94  //                'homedirectory'            => $homedirectory,
  95  //                'mailMessageStore'        => $homedirectory.'/Maildir/',
  96  //                'gidnumber'                => '1000',
  97  //                'qmailDotMode'            => $_accountData['qmailDotMode'],
  98  //                'deliveryProgramPath'    => $_accountData['deliveryProgramPath']
  99              );
 100  
 101              if(!in_array('qmailUser',$objectClasses) &&
 102                  !in_array('qmailuser',$objectClasses))
 103              {
 104                  $objectClasses[]    = 'qmailuser';
 105              }
 106  
 107              // the new code for postfix+cyrus+ldap
 108              $newData = array
 109              (
 110                  'mail'                => $_accountData['mail'],
 111                  'accountStatus'        => $_accountData['accountStatus'],
 112                  'objectclass'        => $objectClasses
 113              );
 114  
 115              if(is_array($_accountData['mailAlternateAddress']))
 116              {
 117                  $newData['mailAlternateAddress'] = $_accountData['mailAlternateAddress'];
 118              }
 119              else
 120              {
 121                  $newData['mailAlternateAddress'] = array();
 122              }
 123  
 124              if($_accountData['accountStatus'] == 'active')
 125              {
 126                  $newData['accountStatus'] = 'active';
 127              }
 128              else
 129              {
 130                  $newData['accountStatus'] = 'disabled';
 131              }
 132  /*
 133              if(!empty($_accountData['deliveryMode']))
 134              {
 135                  $newData['deliveryMode'] = $_accountData['deliveryMode'];
 136              }
 137              else
 138              {
 139                  $newData['deliveryMode'] = array();
 140              }
 141  */
 142  
 143  //            if(is_array($_accountData['mailForwardingAddress']))
 144  //            {
 145                  $newData['mailForwardingAddress'] = $_accountData['mailForwardingAddress'];
 146  //            }
 147  //            else
 148  //            {
 149  //                $newData['mailForwardingAddress'] = array();
 150  //            }
 151  
 152              #print "<br>DN: $accountDN<br>";
 153              ldap_mod_replace ($ldap, $accountDN, $newData);
 154  
 155              // also update the account_email field in egw_accounts
 156              // when using sql account storage
 157              if($GLOBALS['egw_info']['server']['account_repository'] == 'sql')
 158              {
 159                  $this->db->update('egw_accounts',array(
 160                          'account_email'    => $_accountData['mail']
 161                      ),
 162                      array(
 163                          'account_id'    => $_accountID
 164                      ),__LINE__,__FILE__
 165                  );
 166              }
 167          }
 168      }
 169  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7