/** * Hook to update the admin-form when editing / creating a single group * @param class_admin_formgenerator $objForm * * @return mixed */ public function updateAdminForm(class_admin_formgenerator $objForm) { $arrDD = array(); foreach (class_ldap::getAllInstances() as $objOneInstance) { $arrDD[$objOneInstance->getIntCfgNr()] = $objOneInstance->getStrCfgName(); } $objForm->getField("cfg")->setArrKeyValues($arrDD); }
/*"****************************************************************************************************** * (c) 2004-2006 by MulchProductions, www.mulchprod.de * * (c) 2007-2015 by Kajona, www.kajona.de * * Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt * *-------------------------------------------------------------------------------------------------------* * $Id$ * ********************************************************************************************************/ echo "+-------------------------------------------------------------------------------+\n"; echo "| Kajona Debug Subsystem |\n"; echo "| |\n"; echo "| Checks the connection to the configured ldap servers |\n"; echo "| |\n"; echo "+-------------------------------------------------------------------------------+\n"; $intI = 0; foreach (class_ldap::getAllInstances() as $objOneLdap) { $arrCfg = class_config::getInstance("ldap.php")->getConfig($objOneLdap->getIntCfgNr()); echo "Connecting to ldap at " . $arrCfg["ldap_server"] . "\n"; echo "Searching for bind-user " . $arrCfg["ldap_bind_username"] . "\n"; $arrUser = $objOneLdap->getUserdetailsByName($arrCfg["ldap_bind_username"]); var_dump($arrUser); echo "Loading user by DN\n"; $arrUser = $objOneLdap->getUserDetailsByDN($arrUser[0]["identifier"]); var_dump($arrUser); // echo "Loading groups for user\n"; // var_dump($objOneLdap->getMembersOfGroup("CN=Entwickler,OU=Gruppen,DC=ad,DC=artemeon,DC=int")); // var_dump($objOneLdap->getNumberOfGroupMembers("CN=Entwickler,OU=Gruppen,DC=ad,DC=artemeon,DC=int")); } echo "\n\n"; echo "+-------------------------------------------------------------------------------+\n"; echo "| (c) www.kajona.de |\n";
/** * Loads the user identified by the passed name. * This method may be called during the authentication of users and may be used as a hook * in order to create new users in the central database not yet existing. * * @param string $strUsername * * @return interface_usersources_user or null */ public function getUserByUsername($strUsername) { $strQuery = "SELECT user_id FROM " . _dbprefix_ . "user WHERE user_username = ? AND user_subsystem = 'ldap'"; $arrIds = class_carrier::getInstance()->getObjDB()->getPRow($strQuery, array($strUsername)); if (isset($arrIds["user_id"]) && validateSystemid($arrIds["user_id"])) { return new class_usersources_user_ldap($arrIds["user_id"]); } //user not found. search for a matching user in the ldap and add a possible match to the system foreach (class_ldap::getAllInstances() as $objSingleLdap) { $arrDetails = $objSingleLdap->getUserdetailsByName($strUsername); if ($arrDetails !== false && count($arrDetails) == 1) { $arrSingleUser = $arrDetails[0]; $objUser = new class_module_user_user(); $objUser->setStrUsername($strUsername); $objUser->setStrSubsystem("ldap"); $objUser->setIntActive(1); $objUser->setIntAdmin(1); $objUser->updateObjectToDb(); /** @var $objSourceUser class_usersources_user_ldap */ $objSourceUser = $objUser->getObjSourceUser(); if ($objSourceUser instanceof class_usersources_user_ldap) { $objSourceUser->setStrDN($arrSingleUser["identifier"]); $objSourceUser->setStrFamilyname($arrSingleUser["familyname"]); $objSourceUser->setStrGivenname($arrSingleUser["givenname"]); $objSourceUser->setStrEmail($arrSingleUser["mail"]); $objSourceUser->setIntCfg($objSingleLdap->getIntCfgNr()); $objSourceUser->updateObjectToDb(); $this->objDB->flushQueryCache(); return $objSourceUser; } } } return null; }