Changeset 396 for trunk/expressoAdmin1_2/inc/class.sosectors.inc.php
- Timestamp:
- 08/14/08 11:45:39 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoAdmin1_2/inc/class.sosectors.inc.php
r32 r396 13 13 { 14 14 var $functions; 15 var $ldap_connection; 15 16 16 17 function sosectors() 17 18 { 18 19 $this->functions = createobject('expressoAdmin1_2.functions'); 20 21 if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && 22 (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && 23 (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) 24 { 25 $this->ldap_connection = $GLOBALS['phpgw']->common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], 26 $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], 27 $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); 28 } 29 else 30 { 31 $this->ldap_connection = $GLOBALS['phpgw']->common->ldapConnect(); 32 } 19 33 } 20 34 21 35 function exist_sector_name($sector_name, $context) 22 36 { 23 $connection = $GLOBALS['phpgw']->common->ldapConnect(); 24 $search = ldap_list($connection, $context, "ou=" . $sector_name); 25 $result = ldap_get_entries($connection, $search); 37 $search = ldap_list($this->ldap_connection, $context, "ou=" . $sector_name); 38 $result = ldap_get_entries($this->ldap_connection, $search); 26 39 27 40 if ($result['count'] == 0) … … 33 46 function write_ldap($dn, $info) 34 47 { 35 $connection = $GLOBALS['phpgw']->common->ldapConnect(); 36 37 if (ldap_add($connection, $dn, $info)) 48 if (ldap_add($this->ldap_connection, $dn, $info)) 38 49 { 39 50 //Escreve no log 40 51 $this->functions->write_log2($GLOBALS['phpgw']->accounts->data['account_lid'], 'write in ldap', $dn,'','',''); 41 ldap_close($ connection);52 ldap_close($this->ldap_connection); 42 53 return true; 43 54 } … … 45 56 { 46 57 echo 'Erro na escrita no LDAP, funcao write_ldap'; 47 ldap_close($ connection);58 ldap_close($this->ldap_connection); 48 59 return false; 49 60 } … … 52 63 function get_sector_users($context) 53 64 { 54 $connection = $GLOBALS['phpgw']->common->ldapConnect();55 65 $justthese = array("cn", "uidNumber", "uid"); 56 66 $filter="(&(phpgwAccountType=u)(uid=*))"; 57 $search=ldap_search($ connection, $context, $filter, $justthese);58 $result = ldap_get_entries($ connection, $search);67 $search=ldap_search($this->ldap_connection, $context, $filter, $justthese); 68 $result = ldap_get_entries($this->ldap_connection, $search); 59 69 return $result; 60 70 } … … 62 72 function get_sector_groups($context) 63 73 { 64 $connection = $GLOBALS['phpgw']->common->ldapConnect();65 74 $justthese = array("cn", "gidnumber"); 66 75 $filter="(&(phpgwAccountType=g)(cn=*))"; 67 $search=ldap_search($ connection, $context, $filter, $justthese);68 $result = ldap_get_entries($ connection, $search);76 $search=ldap_search($this->ldap_connection, $context, $filter, $justthese); 77 $result = ldap_get_entries($this->ldap_connection, $search); 69 78 return $result; 70 79 } … … 72 81 function get_sector_subsectors($context) 73 82 { 74 $connection = $GLOBALS['phpgw']->common->ldapConnect();75 83 $justthese = array("ou"); 76 84 $filter="(objectClass=organizationalUnit)"; 77 $search=ldap_search($ connection, $context, $filter, $justthese);78 $result = ldap_get_entries($ connection, $search);85 $search=ldap_search($this->ldap_connection, $context, $filter, $justthese); 86 $result = ldap_get_entries($this->ldap_connection, $search); 79 87 return $result; 80 88 } … … 101 109 function get_info($context) 102 110 { 103 $connection = $GLOBALS['phpgw']->common->ldapConnect();104 111 $filter="(objectClass=organizationalUnit)"; 105 $search=ldap_search($ connection, $context, $filter);106 $result = ldap_get_entries($ connection, $search);112 $search=ldap_search($this->ldap_connection, $context, $filter); 113 $result = ldap_get_entries($this->ldap_connection, $search); 107 114 return $result; 108 115 } … … 110 117 function add_attribute($dn, $info) 111 118 { 112 $connection = $GLOBALS['phpgw']->common->ldapConnect(); 113 114 if (ldap_mod_add($connection, $dn, $info)) 119 if (ldap_mod_add($this->ldap_connection, $dn, $info)) 115 120 { 116 ldap_close($ connection);121 ldap_close($this->ldap_connection); 117 122 return true; 118 123 } 119 124 else 120 125 { 121 echo 'Erro na escrita no LDAP, funcao add_attribute: ' . ldap_error($ connection);122 ldap_close($ connection);126 echo 'Erro na escrita no LDAP, funcao add_attribute: ' . ldap_error($this->ldap_connection); 127 ldap_close($this->ldap_connection); 123 128 return false; 124 129 } … … 127 132 function remove_attribute($dn, $info) 128 133 { 129 $connection = $GLOBALS['phpgw']->common->ldapConnect(); 130 131 if (ldap_mod_del($connection, $dn, $info)) 134 if (ldap_mod_del($this->ldap_connection, $dn, $info)) 132 135 { 133 ldap_close($ connection);136 ldap_close($this->ldap_connection); 134 137 return true; 135 138 } 136 139 else 137 140 { 138 echo 'Erro na escrita no LDAP, funcao remove_attribute: ' . ldap_error($ connection);139 ldap_close($ connection);141 echo 'Erro na escrita no LDAP, funcao remove_attribute: ' . ldap_error($this->ldap_connection); 142 ldap_close($this->ldap_connection); 140 143 return false; 141 144 } 142 145 } 143 144 146 } 145 147 ?>
Note: See TracChangeset
for help on using the changeset viewer.