public function doLogin($ps) { $validUntil = Environment::getS("validUntil", null); if ($validUntil != null and $validUntil < time()) { Red::errorD("Diese Version ist abgelaufen. Bitte wenden Sie sich an den Support."); } if (!is_array($ps)) { parse_str($ps, $p); } else { $p = $ps; } #if($p["loginPassword"] == ";;;-1;;;") return 0; $this->doLogout(); $_SESSION["DBData"] = $_SESSION["S"]->getDBData(); try { $U = $this->getUser($p["loginUsername"], $p["loginSHAPassword"], $p["loginPWEncrypted"]); if ($U === null) { return 0; } if (get_class($U) == "phynxAltLogin") { $p["anwendung"] = $U->A("UserApplication"); } if ($U->A("allowedApplications") != null and is_array($U->A("allowedApplications")) and !in_array($p["anwendung"], $U->A("allowedApplications"))) { return 0; } $AC = anyC::get("Userdata", "name", "loginTo" . ((isset($p["isCustomerPage"]) and $p["isCustomerPage"]) ? "customerPage" : $p["anwendung"])); $AC->addAssocV3("UserID", "=", $U->getID()); $UD = $AC->n(); if ($UD != null and $UD->A("wert") == "0") { return 0; } /*$AC = anyC::get("Userdata", "name", "loginToApplication"); $AC->addAssocV3("UserID", "=", $U->getID()); $UD = $AC->n(); if($UD != null AND $UD->A("wert") == "0") return 0;*/ $UA = $U->getA(); } catch (Exception $e) { if ($p["loginUsername"] == "Admin" and $p["loginSHAPassword"] == "4e7afebcfbae000b22c7c85e5560f89a2a0280b4") { #"Admin"){ $tu = new User(-1); $UA = $tu->newAttributes(); $UA->name = "Installations-Benutzer"; $UA->username = "******"; $UA->password = "******"; if ($p["loginSprache"] != "default") { $UA->language = $p["loginSprache"]; } $UA->isAdmin = 1; $U = new User(-1); $U->setA($UA); } else { return -2; } } if ($p["loginSprache"] != "default") { $U->changeA("language", $p["loginSprache"]); } if (strtolower($U->getA()->username) != strtolower($p["loginUsername"])) { return 0; } $_SESSION["S"]->setLoggedInUser($U); $_SESSION["S"]->initApp($p["anwendung"]); if (isset($_COOKIE["phynx_customer"])) { $_SESSION["phynx_customer"] = $_COOKIE["phynx_customer"]; } #if($_SESSION["S"]->checkIfUserLoggedIn()) die("Beim Einloggen ist ein Fehler aufgetreten.\nBitte drücken Sie F5 (aktualisieren) und melden Sie sich erneut an."); return 1; }
public static function getUser($username, $password) { try { $ldap = self::getADConnection($username, $password); if ($ldap == null) { return null; } $LD = LoginData::get("ADServerUserPass"); $result = ldap_search($ldap, $LD->A("optionen"), "(&(objectCategory=person)(samaccountname={$username}))"); #ldap_sort($ldap, $result, "sn"); $info = ldap_get_entries($ldap, $result); foreach ($info as $user) { if (!isset($user["samaccountname"])) { continue; } $R = self::getADEntry($user); $U = new User($R->UserID); $U->setA($R); return $U; } } catch (Exception $e) { } return null; }