/*"****************************************************************************************************** * (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";
/** * Updates all user-data stored in the system. * This may be a long-running task, so execute this only explicitly * and not during common requests! * * @return bool */ public function updateUserData() { //sync may take time -> increase the time available if (@ini_get("max_execution_time") < 500 && @ini_get("max_execution_time") > 0) { @ini_set("max_execution_time", "500"); } $objLdap = class_ldap::getInstance(); //fill all groups - loads new members $arrGroups = $this->getAllGroupIds(); foreach ($arrGroups as $strSingleGroupId) { $objGroup = new class_usersources_group_ldap($strSingleGroupId); $objGroup->getUserIdsForGroup(); } //parse all users $arrUsers = $this->getAllUserIds(); foreach ($arrUsers as $strOneUserId) { $objUser = new class_module_user_user($strOneUserId); /** @var $objSourceUser class_usersources_user_ldap */ $objSourceUser = $objUser->getObjSourceUser(); $arrUserDetails = false; try { $arrUserDetails = $objLdap->getUserDetailsByDN($objSourceUser->getStrDN()); } catch (class_exception $objEx) { } if ($arrUserDetails !== false) { $objSourceUser->setStrDN($arrUserDetails["identifier"]); $objSourceUser->setStrFamilyname($arrUserDetails["familyname"]); $objSourceUser->setStrGivenname($arrUserDetails["givenname"]); $objSourceUser->setStrEmail($arrUserDetails["mail"]); $objSourceUser->updateObjectToDb(); $this->objDB->flushQueryCache(); } else { //user seems to be deleted, remove from system, too $objUser->deleteObject(); } } return true; }
/** * 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); }
/** * Returns the list of group-ids the current user is assigned to * @return array */ public function getGroupIdsForUser() { $arrReturn = array(); $objLdap = class_ldap::getInstance($this->intCfg); $objLdapSource = new class_usersources_source_ldap(); $arrLdapGroups = $objLdapSource->getAllGroupIds(); foreach ($arrLdapGroups as $strOneGroupId) { $objGroup = new class_usersources_group_ldap($strOneGroupId); if ($objGroup->getIntCfg() == $this->intCfg && $objLdap->isUserMemberOfGroup($this->getStrDN(), $objGroup->getStrDn())) { $arrReturn[] = $strOneGroupId; } } return $arrReturn; }