[387] | 1 | <?php |
---|
[4457] | 2 | require_once($_SESSION['rootPath'].'/API/class.servicelocator.php'); |
---|
[176] | 3 | include_once("class.imap_functions.inc.php"); |
---|
[342] | 4 | include_once("class.functions.inc.php"); |
---|
[176] | 5 | |
---|
| 6 | function ldapRebind($ldap_connection, $ldap_url) |
---|
| 7 | { |
---|
| 8 | @ldap_bind($ldap_connection, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); |
---|
| 9 | } |
---|
[387] | 10 | |
---|
[2] | 11 | class ldap_functions |
---|
| 12 | { |
---|
| 13 | var $ds; |
---|
| 14 | var $ldap_host; |
---|
| 15 | var $ldap_context; |
---|
| 16 | var $imap; |
---|
[342] | 17 | var $external_srcs; |
---|
| 18 | var $max_result; |
---|
| 19 | var $functions; |
---|
[4457] | 20 | var $ldapService; |
---|
| 21 | |
---|
[342] | 22 | function ldap_functions(){ |
---|
| 23 | // todo: Page Configuration for External Catalogs. |
---|
| 24 | @include("../contactcenter/setup/external_catalogs.inc.php"); |
---|
[4457] | 25 | $this->ldapService = ServiceLocator::getService('ldap'); |
---|
| 26 | $this->external_srcs = $external_srcs; |
---|
| 27 | $this->max_result = $this->ldapService->limit; |
---|
[387] | 28 | $this->functions = new functions(); |
---|
| 29 | } |
---|
[342] | 30 | // Using ContactCenter configuration. |
---|
| 31 | function ldapConnect($refer = false,$catalog = 0){ |
---|
| 32 | if ($catalog > 0 && is_array($this->external_srcs)){ |
---|
| 33 | $this->ldap_host = $this->external_srcs[$catalog]['host']; |
---|
| 34 | $this->ldap_context = $this->external_srcs[$catalog]['dn']; |
---|
| 35 | $this->bind_dn = $this->external_srcs[$catalog]['acc']; |
---|
| 36 | $this->bind_dn_pw = $this->external_srcs[$catalog]['pw']; |
---|
| 37 | $this->object_class = $this->external_srcs[$catalog]['obj']; |
---|
| 38 | $this->base_dn = $this->external_srcs[$catalog]['dn']; |
---|
| 39 | $this->branch = $this->external_srcs[$catalog]['branch']; |
---|
| 40 | }else { |
---|
[325] | 41 | $this->ldap_host = $_SESSION['phpgw_info']['expressomail']['ldap_server']['host']; |
---|
| 42 | $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn']; |
---|
| 43 | $this->bind_dn = $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc']; |
---|
| 44 | $this->bind_dn_pw = $_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']; |
---|
[387] | 45 | $this->branch = 'ou'; |
---|
[325] | 46 | } |
---|
[387] | 47 | |
---|
[325] | 48 | $this->ds = ldap_connect($this->ldap_host); |
---|
[2] | 49 | ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
[37] | 50 | ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); |
---|
[342] | 51 | if ($refer) { |
---|
[176] | 52 | ldap_set_rebind_proc($this->ds, ldapRebind); |
---|
| 53 | } |
---|
[387] | 54 | @ldap_bind($this->ds,$this->bind_dn,$this->bind_dn_pw ); |
---|
[2] | 55 | } |
---|
| 56 | |
---|
[205] | 57 | //Teste jakjr retornando o DS |
---|
| 58 | function ldapConnect2($refer = false){ |
---|
| 59 | $ds = ldap_connect($_SESSION['phpgw_info']['expressomail']['ldap_server']['host']); |
---|
[387] | 60 | |
---|
[205] | 61 | if (!$ds) |
---|
| 62 | return false; |
---|
[387] | 63 | |
---|
[205] | 64 | ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
| 65 | ldap_set_option($ds, LDAP_OPT_REFERRALS, $refer); |
---|
| 66 | if ($refer) |
---|
| 67 | ldap_set_rebind_proc($ds, ldapRebind); |
---|
| 68 | @ldap_bind($ds, $_SESSION['phpgw_info']['expressomail']['ldap_server']['acc'],$_SESSION['phpgw_info']['expressomail']['ldap_server']['pw']); |
---|
[387] | 69 | |
---|
| 70 | return $ds; |
---|
[205] | 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
[108] | 74 | // usa o host e context do setup. |
---|
[2] | 75 | function ldapRootConnect($refer = false){ |
---|
| 76 | $this->ldap_host = $_SESSION['phpgw_info']['expressomail']['server']['ldap_host']; |
---|
| 77 | $this->ldap_context = $_SESSION['phpgw_info']['expressomail']['server']['ldap_context']; |
---|
| 78 | $this->ds = ldap_connect($this->ldap_host); |
---|
| 79 | ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); |
---|
[37] | 80 | ldap_set_option($this->ds, LDAP_OPT_REFERRALS, $refer); |
---|
[387] | 81 | ldap_bind($this->ds, $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'],$_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); |
---|
[2] | 82 | |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | function quicksearch($params) |
---|
[387] | 86 | { |
---|
[95] | 87 | include_once("class.functions.inc.php"); |
---|
[387] | 88 | $functions = new functions; |
---|
[4929] | 89 | |
---|
| 90 | // $search_for = utf8_encode($params['search_for']); |
---|
| 91 | //Testa se a busca foi realizada com aspas |
---|
| 92 | $search_for = utf8_encode($params['search_for']); |
---|
| 93 | $search_len = (strlen($search_for)) - 1; |
---|
| 94 | $quote_status=false; |
---|
| 95 | |
---|
| 96 | if((($search_for{0}) == "\"") && (($search_for{$search_len}) == "\"")){ |
---|
| 97 | $search_for{0} = " "; |
---|
| 98 | $search_for{$search_len} = " "; |
---|
| 99 | $quote_status=true; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | |
---|
[2] | 104 | $field = $params['field']; |
---|
| 105 | $ID = $params['ID']; |
---|
[4929] | 106 | |
---|
[4457] | 107 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 108 | $filter = $ldapService->getSearchFilter($params['search_for']); |
---|
[4929] | 109 | |
---|
[2] | 110 | $contacts_result = array(); |
---|
| 111 | $contacts_result['field'] = $field; |
---|
| 112 | $contacts_result['ID'] = $ID; |
---|
[4457] | 113 | $search_for = utf8_encode($params['search_for']); |
---|
| 114 | |
---|
[2] | 115 | // follow the referral |
---|
| 116 | $this->ldapConnect(true); |
---|
[4929] | 117 | |
---|
[2] | 118 | if ($this->ds) |
---|
[4929] | 119 | { |
---|
| 120 | if (($field != 'null') && ($ID != 'null')) |
---|
| 121 | { |
---|
| 122 | $filter="(& (&(|(phpgwAccountType=u)(phpgwAccountType=g)(phpgwAccountType=l))(mail=*)) (|(cn=*$search_for*)(mail=*$search_for*)) (!(phpgwaccountvisible=-1)) )"; |
---|
| 123 | if($extendedinfo) |
---|
| 124 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou"); |
---|
| 125 | else |
---|
| 126 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid"); |
---|
| 127 | } |
---|
| 128 | else |
---|
| 129 | { |
---|
| 130 | if($quote_status){ |
---|
| 131 | $filter="(& (phpgwAccountType=u) (|(cn=* $search_for *)(cn=$search_for *)(cn=* $search_for)) (!(phpgwaccountvisible=-1)) )"; |
---|
| 132 | } |
---|
| 133 | else{ |
---|
| 134 | $filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )"; |
---|
| 135 | } |
---|
| 136 | // $filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )"; |
---|
| 137 | if($extendedinfo) |
---|
| 138 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid", "employeeNumber", "ou"); |
---|
| 139 | else |
---|
| 140 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid"); |
---|
| 141 | } |
---|
| 142 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1); |
---|
| 143 | if(!$sr) |
---|
| 144 | return null; |
---|
| 145 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
[342] | 146 | |
---|
[4457] | 147 | $justthese = array("cn", "mail", "telephonenumber", "mobile", "phpgwaccountvisible", "uid", "employeenumber", "ou"); |
---|
| 148 | $types = false; |
---|
[387] | 149 | |
---|
[4457] | 150 | if( $field == 'null' || $ID == 'null' ) |
---|
[4929] | 151 | { |
---|
[4457] | 152 | $justthese[] = "jpegphoto"; |
---|
| 153 | $types = 'u'; |
---|
| 154 | } |
---|
[387] | 155 | |
---|
[4457] | 156 | $filter = $ldapService->getSearchFilter( $params['search_for'], $types ); |
---|
[387] | 157 | |
---|
[4457] | 158 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result); |
---|
| 159 | |
---|
[4929] | 160 | if(!$sr) |
---|
| 161 | return null; |
---|
[4457] | 162 | |
---|
[4929] | 163 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
[4457] | 164 | |
---|
| 165 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 166 | |
---|
| 167 | // New search only on user sector |
---|
| 168 | if ($count_entries == $this->max_result) |
---|
| 169 | { |
---|
| 170 | $overload = $count_entries; |
---|
[4929] | 171 | } |
---|
| 172 | else |
---|
| 173 | { |
---|
| 174 | $catalogsNum=count($this->external_srcs); |
---|
[4457] | 175 | for ($i=0; $i<=$catalogsNum; $i++) { |
---|
[4929] | 176 | if ($this->external_srcs[$i]["quicksearch"]) { |
---|
| 177 | $this->ldapConnect(true,$i); |
---|
| 178 | $filter="(|(cn=*$search_for*)(mail=*$search_for*))"; |
---|
| 179 | $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou"); |
---|
| 180 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1); |
---|
| 181 | if(!$sr) |
---|
| 182 | return null; |
---|
| 183 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
| 184 | $search = ldap_get_entries($this->ds, $sr); |
---|
| 185 | for ($j=0; $j<$search["count"]; $j++) { |
---|
| 186 | $info[] = $search[$j]; |
---|
| 187 | } |
---|
| 188 | $info["count"] = count($info)-1; |
---|
| 189 | } |
---|
[108] | 190 | } |
---|
[95] | 191 | } |
---|
[387] | 192 | |
---|
[4457] | 193 | $tmp = array(); |
---|
| 194 | $tmp_users_from_user_org = array(); |
---|
[387] | 195 | |
---|
[4929] | 196 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 197 | { |
---|
[4457] | 198 | $key = $info[$i]["mail"][0] . '%' . $info[$i]["telephonenumber"][0] . '%'. $info[$i]["mobile"][0] . '%' . $info[$i]["uid"][0] . '%' . $info[$i]["jpegphoto"]['count'] . '%' . $info[$i]["employeenumber"][0] . '%' . $info[$i]["ou"][0]; |
---|
[387] | 199 | |
---|
[4457] | 200 | if (/*(!$quickSearch_only_in_userSector) &&*/ preg_match("/$user_sector_dn/i", $info[$i]['dn'])) |
---|
[4929] | 201 | { |
---|
[4457] | 202 | $tmp_users_from_user_org[$key] = utf8_decode($info[$i]["cn"][0]); |
---|
| 203 | continue; |
---|
[4929] | 204 | } |
---|
[342] | 205 | |
---|
[4457] | 206 | $tmp[$key] = utf8_decode($info[$i]["cn"][0]); |
---|
[4929] | 207 | } |
---|
[387] | 208 | |
---|
[4929] | 209 | natcasesort($tmp_users_from_user_org); |
---|
| 210 | natcasesort($tmp); |
---|
[387] | 211 | |
---|
[4929] | 212 | if (($field != 'null') && ($ID != 'null')) |
---|
| 213 | { |
---|
| 214 | $i = 0; |
---|
[387] | 215 | |
---|
[4929] | 216 | $tmp = array_merge($tmp, $tmp_users_from_user_org); |
---|
| 217 | natcasesort($tmp); |
---|
[271] | 218 | |
---|
[4929] | 219 | foreach ($tmp as $info => $cn) |
---|
| 220 | { |
---|
| 221 | $contacts_result[$i] = array(); |
---|
| 222 | $contacts_result[$i]["cn"] = $cn; |
---|
| 223 | list ($contacts_result[$i]["mail"], $contacts_result[$i]["phone"], $contacts_result[$i]["mobile"], $contacts_result[$i]["uid"], $contacts_result[$i]["jpegphoto"], $contacts_result[$i]["employeenumber"], $contacts_result[$i]["ou"]) = split ('%', $info); |
---|
| 224 | $i++; |
---|
| 225 | } |
---|
| 226 | $contacts_result['quickSearch_only_in_userSector'] = $quickSearch_only_in_userSector; |
---|
[4457] | 227 | $contacts_result['maxResult'] = $ldapService->limit; |
---|
[4929] | 228 | } |
---|
| 229 | else |
---|
| 230 | { |
---|
| 231 | $options_users_from_user_org = ''; |
---|
| 232 | $options = ''; |
---|
[271] | 233 | |
---|
[4457] | 234 | |
---|
[4929] | 235 | $i = 0; |
---|
| 236 | foreach ($tmp_users_from_user_org as $info => $cn) |
---|
| 237 | { |
---|
| 238 | $contacts_result[$i] = array(); |
---|
| 239 | $options_users_from_user_org .= $this->make_quicksearch_card($info, $cn); |
---|
| 240 | $i++; |
---|
| 241 | } |
---|
[387] | 242 | |
---|
[4457] | 243 | |
---|
[4929] | 244 | foreach ($tmp as $info => $cn) |
---|
| 245 | { |
---|
| 246 | $contacts_result[$i] = array(); |
---|
| 247 | $options .= $this->make_quicksearch_card($info, $cn); |
---|
| 248 | $i++; |
---|
| 249 | } |
---|
[271] | 250 | |
---|
[4457] | 251 | |
---|
[4929] | 252 | if (($options_users_from_user_org != '') && ($options != '')) |
---|
| 253 | { |
---|
| 254 | $head_option0 = |
---|
| 255 | '<tr class="quicksearchcontacts_unselected">' . |
---|
| 256 | '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . |
---|
| 257 | $this->functions->getLang('Users from your organization') . '</B> ['.count($tmp_users_from_user_org).']'; |
---|
| 258 | '</td>' . |
---|
| 259 | '</tr>'; |
---|
[4457] | 260 | |
---|
[4929] | 261 | $head_option1 = |
---|
| 262 | '<tr class="quicksearchcontacts_unselected">' . |
---|
| 263 | '<td colspan="2" width="100%" align="center" style="background:#EEEEEE"><B>' . |
---|
| 264 | $this->functions->getLang('Users from others organizations') . '</B> ['.count($tmp).']'; |
---|
| 265 | '</td>' . |
---|
| 266 | '</tr>'; |
---|
| 267 | } |
---|
[4457] | 268 | |
---|
| 269 | $head_option = ''; |
---|
| 270 | |
---|
| 271 | if( $overload ) |
---|
| 272 | $head_option = '<tr class="quicksearchcontacts_unselected">' . |
---|
| 273 | '<td colspan="2" width="100%" align="center" style="background:#EEEEEE; color: red;"><B>' .str_replace('%1', $this->max_result, $this->functions->getLang('More than %1 results. Please, try to refine your search.')) . '</B> '. |
---|
| 274 | '</td>' . |
---|
| 275 | '</tr>'; |
---|
| 276 | |
---|
| 277 | $contacts_result = $head_option.$head_option0 . $options_users_from_user_org . $head_option1. $options; |
---|
| 278 | |
---|
[4929] | 279 | } |
---|
| 280 | } |
---|
[4457] | 281 | |
---|
[4929] | 282 | ldap_close($this->ds); |
---|
[4457] | 283 | |
---|
[4929] | 284 | return $contacts_result; |
---|
[2] | 285 | } |
---|
| 286 | |
---|
[271] | 287 | function make_quicksearch_card($info, $cn) |
---|
| 288 | { |
---|
| 289 | include_once("class.functions.inc.php"); |
---|
[387] | 290 | $functions = new functions; |
---|
| 291 | |
---|
[271] | 292 | $contacts_result = array(); |
---|
| 293 | $contacts_result["cn"] = $cn; |
---|
[3388] | 294 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) |
---|
| 295 | $extendedinfo=true; |
---|
| 296 | else |
---|
| 297 | $extendedinfo=false; |
---|
[387] | 298 | |
---|
[3388] | 299 | list ($contacts_result["mail"], $contacts_result["phone"], $contacts_result["mobile"], $contacts_result["uid"], $contacts_result["jpegphoto"], $contacts_result["employeenumber"], $contacts_result["ou"]) = split ('%', $info); |
---|
| 300 | |
---|
[271] | 301 | if ($contacts_result['jpegphoto']) |
---|
| 302 | $photo_link = '<img src="./inc/show_user_photo.php?mail='.$contacts_result['mail'].'">'; |
---|
| 303 | else |
---|
[1495] | 304 | $photo_link = '<img src="./templates/default/images/photo.jpg">'; |
---|
[387] | 305 | |
---|
[271] | 306 | $phoneUser = $contacts_result['phone']; |
---|
[387] | 307 | |
---|
[271] | 308 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['voip_enabled'] && $phoneUser) { |
---|
[342] | 309 | $phoneUser = '<a title="'.$this->functions->getLang("Call to Comercial Number").'" href="#" onclick="InfoContact.connectVoip(\''.$phoneUser.'\',\'com\')">'.$phoneUser.'</a>'; |
---|
[271] | 310 | if($contacts_result['mobile']){ |
---|
[342] | 311 | $phoneUser .= ' / <a title="'.$this->functions->getLang("Call to Mobile Number").'" href="#" onclick="InfoContact.connectVoip(\''.$contacts_result['mobile'].'\',\'mob\')">'.$contacts_result['mobile'].'</a>'; |
---|
[271] | 312 | } |
---|
| 313 | } |
---|
[3388] | 314 | //verifica de existe o celular do funcionario ($contacts_result["mobile"]), se nao, $phoneUser fica vazia; |
---|
| 315 | |
---|
| 316 | $mobileUser = $contacts_result["mobile"]; |
---|
| 317 | if($mobileUser && !$voipMobile) { |
---|
| 318 | $phoneUser .= " / $mobileUser"; |
---|
| 319 | } |
---|
| 320 | $empNumber = $contacts_result["employeenumber"]; |
---|
| 321 | if($empNumber) { |
---|
| 322 | $empNumber = "$empNumber - "; |
---|
| 323 | } |
---|
| 324 | $ou = $contacts_result["ou"]; |
---|
| 325 | if($ou) { |
---|
| 326 | $ou = "<br/>$ou" ; |
---|
| 327 | } |
---|
| 328 | |
---|
[644] | 329 | // Begin: nickname, firstname and lastname for QuickAdd. |
---|
| 330 | $fn = $contacts_result["cn"]; |
---|
| 331 | $array_name = explode(" ", $fn); |
---|
| 332 | if(count($array_name) > 1){ |
---|
| 333 | $fn = $array_name[0]; |
---|
| 334 | array_shift($array_name); |
---|
| 335 | $sn = implode(" ",$array_name); |
---|
| 336 | } |
---|
| 337 | // End: |
---|
[271] | 338 | $option = |
---|
| 339 | '<tr class="quicksearchcontacts_unselected">' . |
---|
| 340 | '<td class="cc" width="1%">' . |
---|
[342] | 341 | '<a title="'.$this->functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' . |
---|
[271] | 342 | $photo_link . |
---|
| 343 | '</a>' . |
---|
| 344 | '</td>' . |
---|
| 345 | '<td class="cc">' . |
---|
[3388] | 346 | '<span name="cn">' . $empNumber . $contacts_result['cn'] . '</span>' . '<br>' . |
---|
| 347 | '<a title="'.$functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' . |
---|
[271] | 348 | '<font color=blue>' . |
---|
[644] | 349 | '<span name="mail">' . $contacts_result['mail'] . '</span></a></font>'. |
---|
| 350 | '<img src="templates/default/images/user_card.png" style="cursor: pointer;" title="'.$this->functions->getLang("Add Contact").'" onclick="javascript:connector.loadScript(\'ccQuickAdd\');ccQuickAddOne.showList(\''.$fn.','.$fn.','.$sn.','.$contacts_result["mail"].'\')">'. |
---|
| 351 | '<br>' . |
---|
[271] | 352 | $phoneUser . |
---|
[3388] | 353 | $ou . |
---|
[271] | 354 | '</td>' . |
---|
[644] | 355 | '</tr>'; |
---|
[271] | 356 | return $option; |
---|
| 357 | } |
---|
| 358 | |
---|
[387] | 359 | function get_catalogs(){ |
---|
[325] | 360 | $catalogs = array(); |
---|
[387] | 361 | $catalogs[0] = $this->functions->getLang("Global Catalog"); |
---|
| 362 | if($this->external_srcs) |
---|
[342] | 363 | foreach ($this->external_srcs as $key => $valor ){ |
---|
[325] | 364 | $catalogs[$key] = $valor['name']; |
---|
| 365 | } |
---|
| 366 | return $catalogs; |
---|
| 367 | } |
---|
[2] | 368 | function get_organizations($params){ |
---|
| 369 | $organizations = array(); |
---|
[325] | 370 | $params['referral']?$referral = $params['referral']:$referral = false; |
---|
| 371 | $cat = $params['catalog']; |
---|
[2] | 372 | |
---|
[325] | 373 | $this->ldapConnect($referral,$cat); |
---|
| 374 | |
---|
| 375 | if($this->branch != '') { |
---|
[1363] | 376 | $filter="(&(".$this->branch."=*)(!(phpgwAccountVisible=-1)))"; |
---|
[325] | 377 | $justthese = array("$this->branch"); |
---|
[342] | 378 | $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 379 | $info = ldap_get_entries($this->ds, $sr); |
---|
[387] | 380 | |
---|
[3530] | 381 | if($info["count"] == 0) |
---|
| 382 | { |
---|
| 383 | $organizations[0]['ou'] = $this->ldap_context; |
---|
| 384 | } |
---|
| 385 | |
---|
[342] | 386 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 387 | $organizations[$i] = $info[$i]["ou"][0]; |
---|
[325] | 388 | |
---|
[342] | 389 | ldap_close($this->ds); |
---|
[387] | 390 | sort($organizations); |
---|
[342] | 391 | return $organizations; |
---|
[325] | 392 | }else{ |
---|
| 393 | return null; |
---|
[2] | 394 | } |
---|
[342] | 395 | } |
---|
[2] | 396 | function get_organizations2($params){ |
---|
| 397 | $organizations = array(); |
---|
| 398 | $referral = $params['referral']; |
---|
| 399 | $this->ldapRootConnect($referral); |
---|
| 400 | if ($this->ds) { |
---|
[3530] | 401 | $filter="(&(objectClass=organizationalUnit)(!(phpgwAccountVisible=-1)))"; |
---|
[2] | 402 | $justthese = array("ou"); |
---|
| 403 | $sr = ldap_list($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 404 | $info = ldap_get_entries($this->ds, $sr); |
---|
[387] | 405 | |
---|
[3530] | 406 | |
---|
| 407 | if($info["count"] == 0) |
---|
[2] | 408 | { |
---|
[3530] | 409 | $organizations[0]['ou'] = $this->ldap_context; |
---|
| 410 | $organizations[0]['dn'] = $this->ldap_context; |
---|
[2] | 411 | } |
---|
[3530] | 412 | else{ |
---|
| 413 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 414 | { |
---|
| 415 | $organizations[$i]['ou'] = $info[$i]["ou"][0]; |
---|
| 416 | $organizations[$i]['dn'] = $info[$i]["dn"]; |
---|
| 417 | } |
---|
| 418 | } |
---|
[2] | 419 | ldap_close($this->ds); |
---|
[387] | 420 | sort($organizations); |
---|
[2] | 421 | } |
---|
| 422 | return $organizations; |
---|
| 423 | } |
---|
[925] | 424 | //Busca usuarios de um contexto e ja retorna as options do select - usado por template serpro; |
---|
| 425 | function search_users($params) |
---|
[4929] | 426 | { |
---|
| 427 | $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; |
---|
[4457] | 428 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 429 | $ldapService->connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_host'], |
---|
| 430 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], |
---|
| 431 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); |
---|
[4929] | 432 | |
---|
[4457] | 433 | $groups = $ldapService->accountSearch($params['filter'], array("gidNumber","cn"), $params['context'] , 'g', 'cn'); |
---|
| 434 | $users = $ldapService->accountSearch($params['filter'], array("uidNumber","cn"), $params['context'] , 'u', 'cn'); |
---|
| 435 | $group_options = array(); |
---|
| 436 | $user_options = array(); |
---|
| 437 | foreach($groups as $group) |
---|
[4929] | 438 | { |
---|
[4457] | 439 | $group_options[] = '"'.$group['gidNumber'].'U'.'":"'.$group['cn'].'"'; |
---|
[925] | 440 | } |
---|
[4929] | 441 | |
---|
[4457] | 442 | foreach($users as $user) |
---|
[4929] | 443 | { |
---|
[4457] | 444 | if($owner != $user['uidNumber']) |
---|
| 445 | $user_options[] = '"'.$user['uidNumber'].'U'.'":"'.$user['cn'].'"'; |
---|
[4929] | 446 | } |
---|
| 447 | |
---|
[4457] | 448 | $user_options = '{'.implode( ',', $user_options ).'}'; |
---|
| 449 | $group_options = '{'.implode( ',', $group_options ).'}'; |
---|
[4929] | 450 | |
---|
[3909] | 451 | return array("users" => $user_options, "groups" => $group_options); |
---|
[4929] | 452 | } |
---|
[925] | 453 | |
---|
[2] | 454 | function catalogsearch($params) |
---|
[387] | 455 | { |
---|
[4457] | 456 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 457 | $filter = $ldapService->getSearchFilter($params['search_for'],array('u','l','s')); |
---|
| 458 | |
---|
[325] | 459 | $catalog = $params['catalog']; |
---|
[2] | 460 | $error = False; |
---|
[4929] | 461 | |
---|
[4457] | 462 | //if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) |
---|
| 463 | //$extendedinfo=true; |
---|
| 464 | //else |
---|
| 465 | //$extendedinfo=false; |
---|
[387] | 466 | |
---|
[3388] | 467 | |
---|
[381] | 468 | $this->ldapConnect(true,$catalog); |
---|
[387] | 469 | |
---|
| 470 | $params['organization'] == 'all' ? $user_context = $this->ldap_context :$user_context = $this->branch."=".$params['organization'].",".$this->ldap_context; |
---|
| 471 | |
---|
| 472 | if ($this->ds) { |
---|
[4929] | 473 | $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible", "employeeNumber", "ou"); |
---|
[4457] | 474 | $sr=@ldap_search($this->ds, $user_context, $filter, $justthese, 0, $ldapService->limit+1); |
---|
[4929] | 475 | |
---|
[342] | 476 | if(!$sr) |
---|
| 477 | return null; |
---|
[2] | 478 | $count_entries = ldap_count_entries($this->ds,$sr); |
---|
[4457] | 479 | if ($count_entries > $ldapService->limit){ |
---|
[2] | 480 | $info = null; |
---|
[387] | 481 | $error = True; |
---|
[2] | 482 | } |
---|
| 483 | else |
---|
[387] | 484 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 485 | |
---|
| 486 | ldap_close($this->ds); |
---|
| 487 | |
---|
[2] | 488 | $u_tmp = array(); |
---|
| 489 | $g_tmp = array(); |
---|
[387] | 490 | |
---|
[2] | 491 | for ($i=0; $i<$info["count"]; $i++){ |
---|
[325] | 492 | if((!$catalog==0)||(strtoupper($info[$i]["phpgwaccounttype"][0]) == 'U') && ($info[$i]["phpgwaccountvisible"][0] != '-1')) |
---|
| 493 | //aqui eh feita a concatenacao do departamento ao cn; |
---|
| 494 | $u_tmp[$info[$i]["mail"][0]] = utf8_decode($info[$i]["cn"][0]). '%' . $info[$i]["ou"][0]; |
---|
[387] | 495 | if((!$catalog==0)||(strtoupper($info[$i]["phpgwaccounttype"][0]) == 'L') && ($info[$i]["phpgwaccountvisible"][0] != '-1')) |
---|
[325] | 496 | $g_tmp[$info[$i]["mail"][0]] = utf8_decode($info[$i]["cn"][0]); |
---|
[387] | 497 | } |
---|
| 498 | |
---|
[2] | 499 | natcasesort($u_tmp); |
---|
| 500 | natcasesort($g_tmp); |
---|
[387] | 501 | |
---|
[2] | 502 | $i = 0; |
---|
[387] | 503 | $users = array(); |
---|
[325] | 504 | |
---|
[387] | 505 | foreach ($u_tmp as $mail => $cn){ |
---|
| 506 | |
---|
[325] | 507 | $tmp = explode("%", $cn); //explode o cn pelo caracter "%" e joga em $tmp; |
---|
| 508 | $name = $tmp[0]; //pega o primeiro item (cn) do vetor resultante do explode acima; |
---|
| 509 | $department = $tmp[1]; //pega o segundo item (ou) do vetor resultanto do explode acima; |
---|
| 510 | $users[$i++] = array("name" => $name, "email" => $mail, "department" => $department); |
---|
| 511 | |
---|
[2] | 512 | } |
---|
| 513 | unset($u_tmp); |
---|
[387] | 514 | |
---|
| 515 | $i = 0; |
---|
[2] | 516 | $groups = array(); |
---|
[387] | 517 | |
---|
| 518 | foreach ($g_tmp as $mail => $cn){ |
---|
[2] | 519 | $groups[$i++] = array("name" => $cn, "email" => $mail); |
---|
| 520 | } |
---|
| 521 | unset($g_tmp); |
---|
[387] | 522 | |
---|
[4457] | 523 | return array('users' => $users, 'groups' => $groups, 'error' => $error,'maxResult' => $ldapService->limit); |
---|
[387] | 524 | }else |
---|
[2] | 525 | return null; |
---|
| 526 | } |
---|
[387] | 527 | |
---|
[2] | 528 | function get_emails_ldap(){ |
---|
| 529 | |
---|
| 530 | $result['mail']= array(); |
---|
[387] | 531 | $result['mailalter']= array(); |
---|
[2] | 532 | $user = $_SESSION['phpgw_info']['expressomail']['user']['account_lid']; |
---|
| 533 | $this->ldapRootConnect(false); |
---|
| 534 | if ($this->ds) { |
---|
[387] | 535 | $filter="uid=".$user; |
---|
[2] | 536 | $justthese = array("mail","mailAlternateAddress"); |
---|
| 537 | $sr = ldap_search($this->ds,$this->ldap_context, $filter, $justthese); |
---|
| 538 | $ent = ldap_get_entries($this->ds, $sr); |
---|
| 539 | ldap_close($this->ds); |
---|
[387] | 540 | |
---|
[2] | 541 | for ($i=0; $i<$ent["count"]; $i++){ |
---|
| 542 | $result['mail'][] = $ent[$i]["mail"][0]; |
---|
[387] | 543 | $result['mailalter'][] = $ent[$i]["mailalternateaddress"][0]; |
---|
[2] | 544 | } |
---|
| 545 | } |
---|
| 546 | return $result; |
---|
| 547 | } |
---|
[387] | 548 | |
---|
[342] | 549 | //Busca usuarios de um contexto e ja retorna as options do select; |
---|
[2] | 550 | function get_available_users($params) |
---|
[37] | 551 | { |
---|
| 552 | $this->ldapRootConnect(); |
---|
[342] | 553 | //Monta lista de Grupos e Usuarios |
---|
[37] | 554 | $users = Array(); |
---|
| 555 | $groups = Array(); |
---|
| 556 | $user_context= $params['context']; |
---|
| 557 | $owner = $_SESSION['phpgw_info']['expressomail']['user']['owner']; |
---|
[2] | 558 | |
---|
[37] | 559 | if ($this->ds) |
---|
| 560 | { |
---|
| 561 | $justthese = array("gidNumber","cn"); |
---|
| 562 | if ($params['type'] == 'search') |
---|
| 563 | $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 564 | else |
---|
| 565 | $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=g)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 566 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 567 | for ($i=0; $i<$info["count"]; $i++) |
---|
[387] | 568 | $groups[$uids=$info[$i]["gidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => g); |
---|
[37] | 569 | $justthese = array("phpgwaccountvisible","uidNumber","cn"); |
---|
| 570 | if ($params['type'] == 'search') |
---|
| 571 | $sr=ldap_search($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
| 572 | else |
---|
| 573 | $sr=ldap_list($this->ds, $user_context, ("(&(cn=*)(phpgwaccounttype=u)(!(phpgwaccountvisible=-1)))"),$justthese); |
---|
[2] | 574 | |
---|
[37] | 575 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 576 | for ($i=0; $i<$info["count"]; $i++) |
---|
| 577 | { |
---|
| 578 | if ($info[$i]["phpgwaccountvisible"][0] == '-1') |
---|
| 579 | continue; |
---|
| 580 | $users[$uids=$info[$i]["uidnumber"][0]] = Array('name' => $uids=$info[$i]["cn"][0], 'type' => u); |
---|
| 581 | } |
---|
| 582 | } |
---|
| 583 | ldap_close($this->ds); |
---|
[387] | 584 | |
---|
[37] | 585 | @asort($users); |
---|
[387] | 586 | @reset($users); |
---|
[37] | 587 | @asort($groups); |
---|
| 588 | @reset($groups); |
---|
| 589 | $user_options =''; |
---|
| 590 | $group_options =''; |
---|
[2] | 591 | |
---|
[37] | 592 | foreach($groups as $id => $user_array) { |
---|
| 593 | $newId = $id.'U'; |
---|
| 594 | $group_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; |
---|
| 595 | } |
---|
| 596 | foreach($users as $id => $user_array) { |
---|
| 597 | if($owner != $id){ |
---|
| 598 | $newId = $id.'U'; |
---|
| 599 | $user_options .= '<option value="'.$newId.'">'.utf8_decode($user_array['name']).'</option>'."\n"; |
---|
| 600 | } |
---|
| 601 | } |
---|
| 602 | return array("users" => $user_options, "groups" => $group_options); |
---|
| 603 | } |
---|
| 604 | |
---|
[342] | 605 | //Busca usuarios de um contexto e ja retorna as options do select; |
---|
[2] | 606 | function get_available_users2($params) |
---|
| 607 | { |
---|
[4457] | 608 | $ldapService = ServiceLocator::getService('ldap'); |
---|
| 609 | $ldapService->connect($_SESSION['phpgw_info']['expressomail']['server']['ldap_host'], |
---|
| 610 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_dn'], |
---|
| 611 | $_SESSION['phpgw_info']['expressomail']['server']['ldap_root_pw']); |
---|
[4929] | 612 | |
---|
[4457] | 613 | $entries = $ldapService->accountSearch($params['sentence'], array('cn', 'uid'), $params['context'], 'u', 'cn'); |
---|
[4929] | 614 | |
---|
[4457] | 615 | $options = array(); |
---|
[4929] | 616 | |
---|
[4457] | 617 | foreach ($entries as $value) |
---|
| 618 | $options[] = '"'.$value['uid'].'"'.':'.'"'.$value['cn'].'"'; |
---|
[4929] | 619 | |
---|
[4457] | 620 | return "{".implode(',',$options)."}"; |
---|
[4929] | 621 | } |
---|
[387] | 622 | |
---|
[2] | 623 | function uid2cn($uid) |
---|
[387] | 624 | { |
---|
[2] | 625 | // do not follow the referral |
---|
| 626 | $this->ldapRootConnect(false); |
---|
| 627 | if ($this->ds) |
---|
| 628 | { |
---|
[387] | 629 | $filter="(&(phpgwAccountType=u)(uid=$uid))"; |
---|
[2] | 630 | $justthese = array("cn"); |
---|
[344] | 631 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 632 | if(!$sr) |
---|
| 633 | return false; |
---|
[2] | 634 | $info = ldap_get_entries($this->ds, $sr); |
---|
[325] | 635 | return utf8_decode($info[0]["cn"][0]); |
---|
[2] | 636 | } |
---|
| 637 | return false; |
---|
| 638 | } |
---|
[757] | 639 | function uidnumber2uid($uidnumber) |
---|
| 640 | { |
---|
| 641 | // do not follow the referral |
---|
| 642 | $this->ldapRootConnect(false); |
---|
| 643 | if ($this->ds) |
---|
| 644 | { |
---|
| 645 | $filter="(&(phpgwAccountType=u)(uidnumber=$uidnumber))"; |
---|
| 646 | $justthese = array("uid"); |
---|
| 647 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 648 | if(!$sr) |
---|
| 649 | return false; |
---|
| 650 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 651 | return $info[0]["uid"][0]; |
---|
| 652 | } |
---|
| 653 | return false; |
---|
| 654 | } |
---|
[387] | 655 | function getSharedUsersFrom($params){ |
---|
[2] | 656 | $filter = ''; |
---|
[1912] | 657 | $i = 0; |
---|
| 658 | //Added to save if must save sent messages in shared folder |
---|
| 659 | $acl_save_sent_in_shared = array(); |
---|
| 660 | |
---|
[371] | 661 | if($params['uids']) { |
---|
[387] | 662 | $uids = explode(";",$params['uids']); |
---|
[1912] | 663 | $this->imap = new imap_functions(); |
---|
[371] | 664 | foreach($uids as $index => $uid){ |
---|
[387] | 665 | $params = array(); |
---|
[1912] | 666 | //Added to save if user has create permission |
---|
| 667 | $acl_create_message = array(); |
---|
[371] | 668 | $acl = $this->imap->getacltouser($uid); |
---|
[1912] | 669 | if ( preg_match("/a/",$acl )){ |
---|
| 670 | $filter .= "(uid=$uid)"; |
---|
| 671 | if ( preg_match("/p/",$acl )){ |
---|
| 672 | $acl_save_sent_in_shared[ $i ] =$uid; |
---|
| 673 | $i++; |
---|
| 674 | } |
---|
| 675 | } |
---|
| 676 | } |
---|
[2] | 677 | } |
---|
[1912] | 678 | |
---|
[387] | 679 | $this->ldapRootConnect(false); |
---|
[371] | 680 | if ($this->ds) { |
---|
[1912] | 681 | $justthese = array("cn","mail","uid"); |
---|
[371] | 682 | if($filter) { |
---|
[1912] | 683 | $filter="(&(|(phpgwAccountType=u)(phpgwAccountType=s))(|$filter))"; |
---|
[371] | 684 | $sr = ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
[387] | 685 | ldap_sort($this->ds,$sr,"cn"); |
---|
| 686 | $info = ldap_get_entries($this->ds, $sr); |
---|
[1912] | 687 | $var = print_r($acl_save_sent_in_shared, true); |
---|
| 688 | for ($i = 0;$i < $info["count"]; $i++){ |
---|
[371] | 689 | $info[$i]['cn'][0] = utf8_decode($info[$i]['cn'][0]); |
---|
[1912] | 690 | //verify if user has permission to save sent messages in a shared folder |
---|
| 691 | if ( in_array( $info[$i]['uid'][0],$acl_save_sent_in_shared) ){ |
---|
| 692 | $info[$i]['save_shared'][0] = 'y'; |
---|
| 693 | } else $info[$i]['save_shared'][0] = 'n'; |
---|
| 694 | } |
---|
[371] | 695 | } |
---|
[1912] | 696 | |
---|
[371] | 697 | $info['myname'] = $_SESSION['phpgw_info']['expressomail']['user']['fullname']; |
---|
[387] | 698 | |
---|
[371] | 699 | //Find institucional_account. |
---|
| 700 | $filter="(&(phpgwAccountType=i)(mailForwardingAddress=".$_SESSION['phpgw_info']['expressomail']['user']['email']."))"; |
---|
[387] | 701 | $sr = ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
[448] | 702 | ## |
---|
| 703 | # @AUTHOR Rodrigo Souza dos Santos |
---|
| 704 | # @DATE 2008/09/17 |
---|
| 705 | # @BRIEF Changing to ensure that the variable session is always with due value. |
---|
| 706 | ## |
---|
| 707 | if(ldap_count_entries($this->ds,$sr)) |
---|
| 708 | { |
---|
| 709 | ldap_sort($this->ds,$sr,"cn"); |
---|
| 710 | $result = ldap_get_entries($this->ds, $sr); |
---|
| 711 | for ($j = 0;$j < $result["count"]; $j++){ |
---|
| 712 | $info[$i]['cn'][0] = utf8_decode($result[$j]['cn'][0]); |
---|
[1912] | 713 | $info[$i]['mail'][0] = $result[$j]['mail'][0]; |
---|
| 714 | $info[$i]['save_shared'][0] = 'n'; |
---|
| 715 | $info[$i++]['uid'][0] = $result[$j]['uid'][0]; |
---|
[448] | 716 | } |
---|
[371] | 717 | } |
---|
[448] | 718 | |
---|
| 719 | $_SESSION['phpgw_info']['expressomail']['user']['shared_mailboxes'] = $info; |
---|
[1912] | 720 | |
---|
[2] | 721 | return $info; |
---|
| 722 | } |
---|
| 723 | } |
---|
[27] | 724 | |
---|
[205] | 725 | function getUserByEmail($params) |
---|
| 726 | { |
---|
[3163] | 727 | $expires = 60*60*24*30; /* 30 days */ |
---|
| 728 | header("Cache-Control: maxage=".$expires); |
---|
| 729 | header("Pragma: public"); |
---|
| 730 | header("Expires: ".gmdate('D, d M Y H:i:s', time()+$expires)); |
---|
[205] | 731 | $filter="(&(phpgwAccountType=u)(mail=" . $params['email'] . "))"; |
---|
| 732 | $ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn']; |
---|
[3388] | 733 | if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info']) |
---|
| 734 | $extendedinfo=true; |
---|
| 735 | else |
---|
| 736 | $extendedinfo=false; |
---|
[205] | 737 | |
---|
[3388] | 738 | if($extendedinfo) |
---|
| 739 | $justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile","ou","employeeNumber"); |
---|
| 740 | else |
---|
| 741 | $justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile"); |
---|
| 742 | |
---|
[27] | 743 | // Follow the referral |
---|
[205] | 744 | $ds = $this->ldapConnect2(true); |
---|
| 745 | if ($ds) |
---|
[387] | 746 | { |
---|
[342] | 747 | $sr=@ldap_search($ds, $ldap_context, $filter, $justthese); |
---|
[387] | 748 | |
---|
[205] | 749 | if (!$sr) |
---|
| 750 | return null; |
---|
[387] | 751 | |
---|
[205] | 752 | $entry = ldap_first_entry($ds, $sr); |
---|
[387] | 753 | |
---|
| 754 | if($entry) { |
---|
[381] | 755 | $obj = array("cn" => utf8_decode(current(ldap_get_values($ds, $entry, "cn"))), |
---|
[205] | 756 | "email" => $params['email'], |
---|
| 757 | "uid" => ldap_get_values($ds, $entry, "uid"), |
---|
[27] | 758 | "type" => "global", |
---|
[205] | 759 | "mobile" => @ldap_get_values($ds, $entry, "mobile"), |
---|
[3388] | 760 | "telefone" => @ldap_get_values($ds, $entry, "telephonenumber"), |
---|
| 761 | "ou" => @ldap_get_values($ds, $entry, "ou"), |
---|
| 762 | "employeeNumber" => @ldap_get_values($ds, $entry, "employeeNumber") |
---|
[205] | 763 | ); |
---|
[27] | 764 | |
---|
[320] | 765 | $_SESSION['phpgw_info']['expressomail']['contact_photo'] = @ldap_get_values_len($ds, $entry, "jpegphoto"); |
---|
[205] | 766 | ldap_close($ds); |
---|
[27] | 767 | return $obj; |
---|
[205] | 768 | } |
---|
[27] | 769 | } |
---|
| 770 | return null; |
---|
| 771 | } |
---|
[1500] | 772 | |
---|
| 773 | function uid2uidnumber($uid) |
---|
| 774 | { |
---|
| 775 | // do not follow the referral |
---|
| 776 | $this->ldapRootConnect(false); |
---|
| 777 | if ($this->ds) |
---|
| 778 | { |
---|
| 779 | $filter="(&(phpgwAccountType=u)(uid=$uid))"; |
---|
| 780 | $justthese = array("uidnumber"); |
---|
| 781 | $sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese); |
---|
| 782 | if(!$sr) |
---|
| 783 | return false; |
---|
| 784 | $info = ldap_get_entries($this->ds, $sr); |
---|
| 785 | return $info[0]["uidnumber"][0]; |
---|
| 786 | } |
---|
| 787 | return false; |
---|
| 788 | } |
---|
[2] | 789 | } |
---|
[108] | 790 | ?> |
---|