function checkcreds_AD() { $username = $_POST["username"]; $password = trim($_POST["password"]); $account_suffix = null; $q = new mysql_squid_builder(); $results = $q->QUERY_SQL("SELECT * FROM hotspot_activedirectory WHERE enabled=1"); if (mysql_num_rows($results) == 0) { return false; } if (strpos($username, "/") > 0) { $FTR = explode("/", $username); $account_suffix = $FTR[1]; $username = $FTR[0]; } if (strpos($username, "\\") > 0) { $FTR = explode("\\", $username); $account_suffix = $FTR[1]; $username = $FTR[0]; } if (strpos($username, "@") > 0) { $FTR = explode("@", $username); $account_suffix = $FTR[1]; $username = $FTR[0]; } $username_login = strtoupper($username); if ($account_suffix != null) { $username_login = "******"; } while ($ligne = mysql_fetch_assoc($results)) { $ttl = $ligne["ttl"]; $md5 = $ligne["zmd5"]; $groups = trim($ligne["groups"]); $hostname = $ligne["hostname"]; $GLOBALS["AD_SERV_TTL"] = $ttl; if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog(" *********************************************************"); } if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog(" TTL.: {$ttl}Mn"); } if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog(" Host: {$hostname}:389"); } if (!checkcreds_AD_ToServer($hostname, $username, $account_suffix, $password)) { continue; } if (!checkcreds_ADGroups_ToServer($groups, $hostname, $username, $password, $account_suffix)) { continue; } if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog("checkcreds_AD {$ligne["hostname"]} return true... in line:" . __LINE__); } if (checkcreds_AD_ToMemberAD("{$username_login}", $password, $ttl, $md5)) { return true; } } if ($GLOBALS["HOTSPOT_DEBUG"]) { ToSyslog(" ****************** END FUNCTION FAILED ****************** in line:" . __LINE__); } return false; }
function checkcreds_AD($ruleid = 0) { $username = $_POST["username"]; $password = trim($_POST["password"]); $account_suffix = null; $q = new mysql_hotspot(); $results = $q->QUERY_SQL("SELECT * FROM hotspot_activedirectory WHERE enabled=1 AND ruleid='{$ruleid}'"); if (mysql_num_rows($results) == 0) { return false; } if (strpos($username, "/") > 0) { $FTR = explode("/", $username); $account_suffix = $FTR[1]; $username = $FTR[0]; } if (strpos($username, "\\") > 0) { $FTR = explode("\\", $username); $account_suffix = $FTR[1]; $username = $FTR[0]; } if (strpos($username, "@") > 0) { $FTR = explode("@", $username); $account_suffix = $FTR[1]; $username = $FTR[0]; } $username_login = strtoupper($username); if ($account_suffix == null) { $GLOBALS["AD_ERROR"] = "{error_ad_count_suffix}"; return false; } if ($account_suffix != null) { $username_login = "******"; } while ($ligne = mysql_fetch_assoc($results)) { $md5 = $ligne["zmd5"]; $groups = trim($ligne["groups"]); $hostname = $ligne["hostname"]; wifidog_logs("{$username_login} -> {$hostname}:389"); if (!checkcreds_AD_ToServer($hostname, $username, $account_suffix, $password)) { wifidog_logs("{$username_login} -> {$hostname}:389 -> failed"); continue; } if (!checkcreds_ADGroups_ToServer($groups, $hostname, $username, $password, $account_suffix)) { continue; } if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs("checkcreds_AD {$ligne["hostname"]} return true... in line:" . __LINE__); } if (checkcreds_AD_ToMemberAD("{$username_login}", $password, 0, $md5)) { return true; } } if ($GLOBALS["HOTSPOT_DEBUG"]) { wifidog_logs(" ****************** END FUNCTION FAILED ****************** in line:" . __LINE__); } return false; }