HOR-3221 improvement

This commit is contained in:
Roly Rudy Gutierrez Pinto
2017-09-19 11:19:45 -04:00
parent 0df3a018c4
commit 59fc56265a
3 changed files with 281 additions and 318 deletions

View File

@@ -435,33 +435,40 @@ class RBAC
foreach ($this->aRbacPlugins as $sClassName) { foreach ($this->aRbacPlugins as $sClassName) {
$plugin = new $sClassName(); $plugin = new $sClassName();
if (method_exists( $plugin, 'automaticRegister' )) { if (method_exists($plugin, 'automaticRegister')) {
$oCriteria = new Criteria( 'rbac' ); $oCriteria = new Criteria('rbac');
$oCriteria->add( AuthenticationSourcePeer::AUTH_SOURCE_PROVIDER, $sClassName ); $oCriteria->add(AuthenticationSourcePeer::AUTH_SOURCE_PROVIDER, $sClassName);
$oCriteria->addAscendingOrderByColumn( AuthenticationSourcePeer::AUTH_SOURCE_NAME ); $oCriteria->addAscendingOrderByColumn(AuthenticationSourcePeer::AUTH_SOURCE_NAME);
$oDataset = AuthenticationSourcePeer::doSelectRS( $oCriteria, Propel::getDbConnection('rbac_ro') ); $oDataset = AuthenticationSourcePeer::doSelectRS($oCriteria, Propel::getDbConnection('rbac_ro'));
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next(); $oDataset->next();
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
while (is_array( $aRow )) { while (is_array($aRow)) {
$aRow = array_merge( $aRow, unserialize( $aRow['AUTH_SOURCE_DATA'] ) ); $aRow = array_merge($aRow, unserialize($aRow['AUTH_SOURCE_DATA']));
//Check if this authsource is enabled for AutoRegister, if not skip this //Check if this authsource is enabled for AutoRegister, if not skip this
if ($aRow['AUTH_SOURCE_AUTO_REGISTER'] == 1) { if ($aRow['AUTH_SOURCE_AUTO_REGISTER'] == 1) {
$plugin->sAuthSource = $aRow['AUTH_SOURCE_UID']; $plugin->sAuthSource = $aRow['AUTH_SOURCE_UID'];
$plugin->sSystem = $this->sSystem; $plugin->sSystem = $this->sSystem;
//search the usersRolesObj //search the usersRolesObj
//create the users in ProcessMaker //create the users in ProcessMaker
$res = $plugin->automaticRegister( $aRow, $strUser, $strPass ); try {
$res = $plugin->automaticRegister($aRow, $strUser, $strPass);
if ($res == 1) { if ($res == 1) {
return $res; return $res;
} }
} catch (Exception $e) {
$context = Bootstrap::getDefaultContextLog();
$context["action"] = "ldapSynchronize";
$context["authSource"] = $aRow;
Bootstrap::registerMonolog("ldapSynchronize", 400, $e->getMessage(), $context, $context["workspace"], "processmaker.log");
}
} }
$oDataset->next(); $oDataset->next();
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
} }
} }
} }
return $result;
} }
/** /**

View File

@@ -1180,7 +1180,7 @@ class LdapAdvanced
} }
if ($validUserPass == 1) { if ($validUserPass == 1) {
$this->log($ldapcnn, "sucessful login user " . $verifiedUser["sDN"]); $this->log($ldapcnn, "sucessful login user " . $userDn);
} else { } else {
$this->log($ldapcnn, "failure authentication for user $strUser"); $this->log($ldapcnn, "failure authentication for user $strUser");
} }

View File

@@ -71,7 +71,7 @@ class ldapadvancedClassCron
foreach ($arrayAuthenticationSource as $value) { foreach ($arrayAuthenticationSource as $value) {
$arrayAuthenticationSourceData = $value; $arrayAuthenticationSourceData = $value;
try {
$plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$arrayAuthenticationSourceData ---->\n" . print_r($arrayAuthenticationSourceData, true)); $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$arrayAuthenticationSourceData ---->\n" . print_r($arrayAuthenticationSourceData, true));
$plugin->sAuthSource = $arrayAuthenticationSourceData["AUTH_SOURCE_UID"]; $plugin->sAuthSource = $arrayAuthenticationSourceData["AUTH_SOURCE_UID"];
@@ -141,17 +141,6 @@ class ldapadvancedClassCron
foreach ($aRegisteredDepts as $registeredDept) { foreach ($aRegisteredDepts as $registeredDept) {
$count++; $count++;
//(D) Update Users
//if (!isset($arrayDepartmentUserAd[$registeredDept["DEP_UID"]])) {
// $arrayDepartmentUserAd[$registeredDept["DEP_UID"]] = array(); //Current users in department based in Active Directory
//}
//
//$arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept);
//$arrayAux = array_merge($arrayDepartmentUserAd[$registeredDept["DEP_UID"]], $arrayAux);
//
//$arrayDepartmentUserAd[$registeredDept["DEP_UID"]] = array_unique($arrayAux);
$arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept); $arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept);
} }
@@ -177,17 +166,6 @@ class ldapadvancedClassCron
foreach ($aRegisteredGroups as $registeredGroup) { foreach ($aRegisteredGroups as $registeredGroup) {
$count++; $count++;
//(G) Update Users
//if (!isset($arrayGroupUserAd[$registeredGroup["GRP_UID"]])) {
// $arrayGroupUserAd[$registeredGroup["GRP_UID"]] = array(); //Current users in group based in Active Directory
//}
//
//$arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup);
//$arrayAux = array_merge($arrayGroupUserAd[$registeredGroup["GRP_UID"]], $arrayAux);
//
//$arrayGroupUserAd[$registeredGroup["GRP_UID"]] = array_unique($arrayAux);
$arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup); $arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup);
} }
@@ -386,37 +364,15 @@ class ldapadvancedClassCron
//Update Users data based on the LDAP Server //Update Users data based on the LDAP Server
$plugin->usersUpdateData($arrayAuthenticationSourceData["AUTH_SOURCE_UID"]); $plugin->usersUpdateData($arrayAuthenticationSourceData["AUTH_SOURCE_UID"]);
} catch (Exception $e) {
$context = Bootstrap::getDefaultContextLog();
$context["action"] = "ldapSynchronize";
$context["authSource"] = $arrayAuthenticationSourceData;
Bootstrap::registerMonolog("ldapSynchronize", 400, $e->getMessage(), $context, $context["workspace"], "processmaker.log");
}
} }
$plugin->frontEndShow("END"); $plugin->frontEndShow("END");
//(D) Update Users
////Department //Upgrade users in departments
//foreach ($arrayDepartmentUserAd as $departmentUid => $arrayUserAd) {
// $plugin->setArrayDepartmentUsers($departmentUid); //INITIALIZE DATA
//
// $arrayAux = array_diff(array_keys($plugin->arrayDepartmentUsersByUid), $arrayUserAd);
//
// $this->departmentRemoveUsers($departmentUid, $arrayAux);
//}
//(G) Update Users
////Group //Upgrade users in groups
//foreach ($arrayGroupUserAd as $groupUid => $arrayUserAd) {
// $plugin->setArrayGroupUsers($groupUid); //INITIALIZE DATA
//
// $arrayAux = array_diff(array_keys($plugin->arrayGroupUsersByUid), $arrayUserAd);
//
// $this->groupRemoveUsers($groupUid, $arrayAux);
//}
//// Developed by Gary and Ronald
//$usersInfo = $plugin->ASUpdateInfo('');
//if (isset($usersInfo) && $usersInfo > 0) {
// $this->dMoved = $usersInfo;
//}
//// End Developed by Gary and Ronald
$plugin->debugLog("END"); $plugin->debugLog("END");
} }