Changeset 397


Ignore:
Timestamp:
08/14/08 11:46:29 (16 years ago)
Author:
niltonneto
Message:

Otimizações feitas na classe ldap da API, trazendo apenas os
atributos necessários para o retorno.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/class.accounts_ldap.inc.php

    r367 r397  
    5656                        if(($acct_type == 'g') && $this->group_context) 
    5757                        { 
    58                                   $sri = @ldap_search($this->ds, $this->user_context, ("(&(gidnumber=" . (int)$this->account_id.")(phpgwaccounttype=g))")); 
    59                         } 
    60                         else 
    61                         { 
    62                                   $sri = @ldap_search($this->ds, $this->group_context, ("(&(uidnumber=" . (int)$this->account_id.")(phpgwaccounttype=u))")); 
     58                                /* jakjr: using justthese with ldap_search */ 
     59                                $justthese = array("gidnumber", "cn"); 
     60                                $sri = @ldap_search($this->ds, $this->group_context, ("(&(gidnumber=" . (int)$this->account_id.")(phpgwaccounttype=g))"), $justthese); 
     61                        } 
     62                        else 
     63                        { 
     64                                /* jakjr: using justthese with ldap_search */ 
     65                                $justthese = array("uidnumber", "gidnumber", "uid", "cn", "givenname", "sn", "mail", "phpgwaccountstatus", "phpgwaccountexpires", "phpgwaccounttype"); 
     66                                $sri = @ldap_search($this->ds, $this->user_context, ("(&(uidnumber=" . (int)$this->account_id.")(phpgwaccounttype=u))"), $justthese); 
    6367                        } 
    6468                        if(!$sri) 
     
    8589                                        $this->data['email'] = $allValues[0]['mail'][0]; 
    8690                                } 
     91                                /* jakjr: this is not used for expressoLivre */ 
     92                                /* 
     93                                $this->data['telephonenumber']   = $allValues[0]['telephonenumber'][0]; 
     94                                $this->data['lastlogin']         = $allValues[0]['phpgwaccountlastlogin'][0]; 
     95                                $this->data['lastloginfrom']     = $allValues[0]['phpgwaccountlastloginfrom'][0]; 
     96                                $this->data['lastpasswd_change'] = @$allValues[0]['phpgwlastpasswdchange'][0]; 
     97                                */ 
     98                                $this->data['status']            = trim($allValues[0]['phpgwaccountstatus'][0]); 
     99                                $this->data['expires']           = $allValues[0]['phpgwaccountexpires'][0]; 
     100                                $this->data['type']              = $allValues[0]['phpgwaccounttype'][0]; 
    87101                        } 
    88102                        $this->data['account_dn']  = $allValues[0]['dn']; 
    89103                        $this->data['fullname']    = $GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8'); 
    90104 
     105                        /* jakjr: this is not used for expressoLivre */ 
     106                        /* 
    91107                        if ($GLOBALS['phpgw_info']['server']['ldap_extra_attributes']) 
    92108                        { 
     
    94110                                $this->data['loginshell'] = $allValues[0]['loginshell'][0]; 
    95111                        } 
    96                          
    97                         $this->data['telephonenumber']   = $allValues[0]['telephonenumber'][0]; 
    98                         $this->data['lastlogin']         = $allValues[0]['phpgwaccountlastlogin'][0]; 
    99                         $this->data['lastloginfrom']     = $allValues[0]['phpgwaccountlastloginfrom'][0]; 
    100                         $this->data['lastpasswd_change'] = @$allValues[0]['phpgwlastpasswdchange'][0]; 
    101                         $this->data['status']            = trim($allValues[0]['phpgwaccountstatus'][0]); 
    102                         $this->data['type']              = $allValues[0]['phpgwaccounttype'][0]; 
    103                         $this->data['expires']           = $allValues[0]['phpgwaccountexpires'][0]; 
    104  
     112                        */ 
    105113                        return $this->data; 
    106114                } 
     
    578586                function name2id($name,$which='account_lid') 
    579587                { 
    580                         if ($which == 'account_lid')    // groups only support account_lid 
    581                         { 
    582                                 $sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . (string)$name . ')(phpgwaccounttype=g))'); 
    583                                 $allValues = ldap_get_entries($this->ds, $sri); 
    584          
    585                                 if (@$allValues[0]['gidnumber'][0]) 
    586                                 { 
    587                                         return (int)$allValues[0]['gidnumber'][0]; 
    588                                 } 
    589                         } 
     588                        /* jakjr: change search position */ 
    590589                        $to_ldap = array( 
    591590                                'account_lid'   => 'uid', 
     
    593592                        ); 
    594593                        if (!isset($to_ldap[$which])) return False; 
    595  
    596                         $sri = ldap_search($this->ds, $this->user_context, '(&('.$to_ldap[$which].'=' . (string)$name . ')(phpgwaccounttype=u))'); 
    597  
     594                         
     595                        $sri = ldap_search($this->ds, $this->user_context, '(&('.$to_ldap[$which].'=' . (string)$name . ')(phpgwaccounttype=u))', array("uidnumber")); 
    598596                        $allValues = ldap_get_entries($this->ds, $sri); 
    599597 
     
    603601                        } 
    604602 
     603                        if ($which == 'account_lid')    // groups only support account_lid 
     604                        { 
     605                                $sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . (string)$name . ')(phpgwaccounttype=g))', array("gidnumber")); 
     606                                $allValues = ldap_get_entries($this->ds, $sri); 
     607         
     608                                if (@$allValues[0]['gidnumber'][0]) 
     609                                { 
     610                                        return (int)$allValues[0]['gidnumber'][0]; 
     611                                } 
     612                        } 
     613                         
    605614                        return False; 
    606615                } 
     
    611620                        { 
    612621                                $allValues = array(); 
    613                                 $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))'); 
     622                                /* jakjr: using justthese with ldap_search */ 
     623                                $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))', array("cn")); 
    614624                                if(!$sri) 
    615625                                        return False; 
     
    632642 
    633643                        $allValues = array(); 
    634                         $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))'); 
     644                        /* jakjr: using justthese with ldap_search */ 
     645                        $justthese = array("uid","mail","surname","cn","phpgwaccounttype"); 
     646                        $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))', $justthese); 
    635647                        if(!$sri) 
    636648                                return False; 
     
    647659                { 
    648660                        $allValues = array(); 
    649                         $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))'); 
     661                        /* jakjr: using justthese with ldap_search */ 
     662                        $sri = @ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))', array("phpgwaccounttype")); 
    650663                        if(!$sri) 
    651664                                return False; 
     
    658671 
    659672                        $allValues = array(); 
    660                         $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))'); 
     673                        /* jakjr: using justthese with ldap_search */ 
     674                        $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))', array("phpgwaccounttype")); 
    661675                        if(!$sri) 
    662676                                return False; 
     
    10841098                        $acct_type = $this->get_type($account_id); 
    10851099 
     1100                        /* jakjr: using justthese with ldap_search */ 
     1101                        $justthese = array("cn","uid","givename","sn"); 
     1102 
    10861103                        /* search the dn for the given uid */ 
    10871104                        if(($acct_type == 'g') && $this->group_context) 
    10881105                        { 
    1089                                 $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwAccountType=g))'); 
    1090                         } 
    1091                         else 
    1092                         { 
    1093                                 $sri = @ldap_search($this->ds, $this->user_context, 'uidnumber=' . (int)$account_id); 
     1106                                $sri = @ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwAccountType=g))', $justthese); 
     1107                        } 
     1108                        else 
     1109                        { 
     1110                                $sri = @ldap_search($this->ds, $this->user_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwAccountType=g))', $justthese); 
    10941111                        } 
    10951112                        if(!$sri) 
Note: See TracChangeset for help on using the changeset viewer.