function impcomputers() { $sock = new sockets(); $ldap = new clladp(); $users = new usersMenus(); $EnableKerbAuth = 1; if (!$ldap->IsKerbAuth()) { $EnableKerbAuth = 0; } if (!is_numeric($EnableKerbAuth)) { $EnableKerbAuth = 0; } if ($GLOBALS["VERBOSE"]) { echo "EnableKerbAuth={$EnableKerbAuth}\n"; } if ($EnableKerbAuth == 0) { return; } $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/exec.adusers.php.impcomputers.time"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, __FILE__)) { return; } $ztime = $unix->file_time_min($timefile); if ($ztime < 240) { die; } @unlink($timefile); @file_put_contents($timefile, time()); array('a', 'b', 'c', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'); $iptcp = new IP(); while (list($num, $letter) = each($array)) { $ad = new external_ad_search(); $CMPS = $ad->find_computers("{$letter}*"); $count = $CMPS["count"]; if ($GLOBALS["VERBOSE"]) { echo "{$letter}* == {$count}\n"; } for ($i = 0; $i < $count; $i++) { $arraCMP = $CMPS[$i]; $hostname = null; $domain = null; $operatingsystem = null; $uid = $arraCMP["samaccountname"][0]; $computer = new computers($uid); if ($computer->IsExists) { continue; } if (isset($arraCMP["dnshostname"][0])) { $hostname = $arraCMP["dnshostname"][0]; } if (isset($arraCMP["operatingsystem"][0])) { $operatingsystem = $arraCMP["operatingsystem"][0]; } if ($hostname == null) { if (isset($arraCMP["name"])) { $hostname = $arraCMP["name"][0]; } } if ($hostname == null) { if (isset($arraCMP["cn"])) { $hostname = $arraCMP["cn"][0]; } } if ($hostname == null) { continue; } if (strpos($hostname, ".") > 0) { $DD = explode(".", $hostname); unset($DD[0]); $domain = @implode(".", $DD); } $ipaddr = gethostbyname($hostname); if (!$iptcp->isIPAddress($ipaddr)) { if ($GLOBALS["VERBOSE"]) { echo "{$hostname} - > {$ipaddr} -> abort\n"; } continue; } $computer->ComputerIP = $ipaddr; $computer->uid = "{$uid}"; if ($domain != null) { $computer->DnsZoneName = $domain; } $computer->ComputerRealName = $arraCMP["name"]; $computer->ComputerOS = $operatingsystem; if ($GLOBALS["VERBOSE"]) { echo "Add {$hostname}/{$ipaddr} {$operatingsystem}\n"; } $computer->Add(); } } }