TASK-230 Delete old ldap files

This commit is contained in:
Brayan Pereyra
2025-09-18 13:28:30 +00:00
parent a7fe9048bf
commit ad443416ea
13 changed files with 0 additions and 4850 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +0,0 @@
<?php
/**
* Maintained for compatibility reasons.
* @deprecated 3.2.2, File maintained only for backward compatibility because it is used in plugins
*/

View File

@@ -1,425 +0,0 @@
<?php
class treeNode extends stdclass
{
public $text = "";
public $cls = "";
public $leaf = false;
public $checked = false;
public $children = array();
public $id = "";
}
try {
header("Content-Type: application/json;");
switch ($_REQUEST["m"]) {
case "loadDepartments":
global $ldapAdvanced;
global $departments;
global $terminatedOu;
global $baseDN;
$ldapAdvanced = getLDAPAdvanceInstance($_REQUEST["authUid"]);
$RBAC = RBAC::getSingleton();
$authenticationSource = $RBAC->authSourcesObj->load($_REQUEST["authUid"]);
$baseDN = $authenticationSource["AUTH_SOURCE_BASE_DN"];
$departments = $ldapAdvanced->searchDepartments();
$terminatedOu = $ldapAdvanced->getTerminatedOu();
$nodes = lookForChildrenDeps("");
die(json_encode($nodes));
break;
case "saveDepartments":
$depsToCheck = ($_REQUEST['departmentsDN'] != '') ? explode('|', $_REQUEST['departmentsDN']) : [];
$depsToCheck = array_map("urldecode", $depsToCheck);
$depsToUncheck = getDepartmentsToUncheck($depsToCheck);
$RBAC = RBAC::getSingleton();
$authenticationSource = $RBAC->authSourcesObj->load($_REQUEST["authUid"]);
$ldapAdvanced = getLDAPAdvanceInstance($_REQUEST["authUid"]);
foreach ($depsToCheck as $departmentDn) {
$departmentUid = $ldapAdvanced->getDepUidIfExistsDN($departmentDn);
if ($departmentUid == '') {
if (strcasecmp($departmentDn, $authenticationSource['AUTH_SOURCE_BASE_DN']) == 0) {
$departmentTitle = 'ROOT (' . $authenticationSource['AUTH_SOURCE_BASE_DN'] . ')';
$parentUid = '';
} else {
$ous = custom_ldap_explode_dn($departmentDn);
$departmentCurrent = array_shift($ous);
$parentDn = implode(',', $ous);
$ous = explode('=', $departmentCurrent);
$departmentTitle = trim($ous[1]);
$parentUid = $ldapAdvanced->getDepUidIfExistsDN($parentDn);
if (str_ireplace($authenticationSource['AUTH_SOURCE_BASE_DN'], '', $parentDn) != '' && $parentUid == '') {
$response = new stdClass();
$response->status = 'ERROR';
$response->message = G::LoadTranslation(
'ID_DEPARTMENT_CHECK_PARENT_DEPARTMENT',
[$parentDn, $departmentTitle]
);
echo json_encode($response);
exit(0);
}
}
$departmentUid = $ldapAdvanced->getDepartmentUidByTitle($departmentTitle);
$department = new Department();
if ($departmentUid === '') {
$data = [
'DEP_TITLE' => stripslashes($departmentTitle),
'DEP_PARENT' => $parentUid,
'DEP_LDAP_DN' => $departmentDn,
'DEP_REF_CODE' => ''
];
$departmentUid = $department->create($data);
if ($departmentUid === false) {
$response = new stdClass();
$response->status = 'ERROR';
$response->message = G::LoadTranslation('ID_DEPARTMENT_ERROR_CREATE');
echo json_encode($response);
exit(0);
}
} else {
$data = $department->Load($departmentUid);
$data['DEP_LDAP_DN'] = $departmentDn;
$department->update($data);
}
}
}
if (count($depsToUncheck) > 0) {
$baseDnLength = strlen($authenticationSource['AUTH_SOURCE_BASE_DN']);
foreach ($depsToUncheck as $departmentDn) {
$departmentUid = $ldapAdvanced->getDepUidIfExistsDN($departmentDn);
if ($departmentUid != '' &&
strcasecmp(
substr($departmentDn, strlen($departmentDn) - $baseDnLength),
$authenticationSource['AUTH_SOURCE_BASE_DN']
) == 0
) {
$department = new Department();
$data = $department->Load($departmentUid);
$data['DEP_LDAP_DN'] = '';
$department->update($data);
if (!isset($authenticationSource['AUTH_SOURCE_DATA']['DEPARTMENTS_TO_UNASSIGN'])) {
$authenticationSource['AUTH_SOURCE_DATA']['DEPARTMENTS_TO_UNASSIGN'] = [];
}
$authenticationSource['AUTH_SOURCE_DATA']['DEPARTMENTS_TO_UNASSIGN'][] = $departmentUid;
}
}
$RBAC->authSourcesObj->update($authenticationSource);
}
$response = new stdclass();
$response->status = "OK";
if ($ldapAdvanced->checkDuplicateDepartmentTitles()) {
$response->warning = G::LoadTranslation("ID_IT_WAS_IDENTIFIED_DUPLICATED_DEPARTMENTS_PLEASE_REMOVE_THESE_DEPARTMENTS");
}
die(json_encode($response));
break;
case "loadGroups":
global $ldapAdvanced;
global $groups;
$ldapAdvanced = getLDAPAdvanceInstance($_REQUEST["authUid"]);
$groups = $ldapAdvanced->searchGroups();
$nodes = lookForChildrenGroups();
die(json_encode($nodes));
break;
case "saveGroups":
$groupsToCheck = explode("|", $_REQUEST["groupsDN"]);
$groupsToCheck = array_map("urldecode", $groupsToCheck);
$groupsToUncheck = getGroupsToUncheck($groupsToCheck);
$RBAC = RBAC::getSingleton();
$authenticationSource = $RBAC->authSourcesObj->load($_REQUEST["authUid"]);
$ldapAdvanced = getLDAPAdvanceInstance($_REQUEST["authUid"]);
foreach ($groupsToCheck as $groupDN) {
$ous = custom_ldap_explode_dn($groupDN);
$currentGroup = array_shift($ous);
$groupAux = explode("=", $currentGroup);
$groupTitle = isset($groupAux[1]) ? trim($groupAux[1]) : "";
$groupTitle = stripslashes($groupTitle);
if (empty($groupTitle)) {
continue;
}
$groupUid = $ldapAdvanced->getGroupUidByTitle($groupTitle);
$groupwf = new Groupwf();
if ($groupUid === "") {
$group = [
"GRP_TITLE" => $groupTitle,
"GRP_LDAP_DN" => $groupDN
];
$groupwf->create($group);
} else {
$group = $groupwf->Load($groupUid);
$group["GRP_LDAP_DN"] = $groupDN;
$groupwf->update($group);
}
}
if (count($groupsToUncheck) > 0) {
foreach ($groupsToUncheck as $groupDN) {
$ous = custom_ldap_explode_dn($groupDN);
$currentGroup = array_shift($ous);
$groupAux = explode("=", $currentGroup);
$groupTitle = isset($groupAux[1]) ? trim($groupAux[1]) : "";
$groupTitle = stripslashes($groupTitle);
if (empty($groupTitle)) {
continue;
}
$groupUid = $ldapAdvanced->getGroupUidByTitle($groupTitle);
if ($groupUid != "") {
$groupwf = new Groupwf();
$group = $groupwf->Load($groupUid);
$group["GRP_LDAP_DN"] = "";
$groupwf->update($group);
if (!isset($authenticationSource["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"])) {
$authenticationSource["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"] = [];
}
$authenticationSource["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"][] = $groupUid;
}
}
$RBAC->authSourcesObj->update($authenticationSource);
}
$response = new stdclass();
$response->status = "OK";
if ($ldapAdvanced->checkDuplicateTitles()) {
$response->warning = G::LoadTranslation("ID_IT_WAS_IDENTIFIED_DUPLICATED_GROUPS_PLEASE_REMOVE_THESE_GROUPS");
}
die(json_encode($response));
break;
}
} catch (Exception $error) {
$response = new stdclass();
$response->status = "ERROR";
$response->message = $error->getMessage();
die(json_encode($response));
}
function getLDAPAdvanceInstance($authUid)
{
$RBAC = RBAC::getSingleton();
$ldapAdvanced = new LdapAdvanced();
$ldapAdvanced->sAuthSource = $authUid;
$ldapAdvanced->sSystem = $RBAC->sSystem;
return $ldapAdvanced;
}
function getDepartments($parent)
{
global $departments;
global $terminatedOu;
global $baseDN;
$parentDepartments = $departments;
$childDepartments = $departments;
$currentDepartments = array();
foreach ($parentDepartments as $key => $val) {
if (strtolower($val["dn"]) != strtolower($parent)) {
if ((strtolower($val["parent"]) == strtolower($parent)) && (strtolower($val["ou"]) != strtolower($terminatedOu))) {
$node = array();
$node["DEP_UID"] = $val["ou"];
$node["DEP_TITLE"] = $val["ou"];
$node["DEP_USERS"] = $val["users"];
$node["DEP_DN"] = $val["dn"];
$node["HAS_CHILDREN"] = false;
$departments[$key]["hasChildren"] = false;
foreach ($childDepartments as $key2 => $val2) {
if (strtolower($val2["parent"]) == strtolower($val["dn"])) {
$node["HAS_CHILDREN"] = true;
$departments[$key]["hasChildren"] = true;
break;
}
}
$node["DEP_LAST"] = false;
$currentDepartments[] = $node;
}
}
}
if (isset($currentDepartments[count($currentDepartments) - 1])) {
$currentDepartments[count($currentDepartments) - 1]["DEP_LAST"] = true;
}
return $currentDepartments;
}
function lookForChildrenDeps($parent)
{
global $ldapAdvanced;
global $departments;
$allDepartments = getDepartments($parent);
$departmentsObjects = array();
$arrayDepartmentNumberOfUsersFromDb = $ldapAdvanced->departmentsGetNumberOfUsersFromDb();
foreach ($allDepartments as $department) {
$departmentObject = new treeNode();
$departmentObject->text = htmlentities($department["DEP_TITLE"], ENT_QUOTES, "UTF-8");
$departmentUid = $ldapAdvanced->getDepUidIfExistsDN($department["DEP_DN"]);
if ($departmentUid != "") {
$departmentObject->text .= " (" . ((isset($arrayDepartmentNumberOfUsersFromDb[$departmentUid])) ? $arrayDepartmentNumberOfUsersFromDb[$departmentUid] : 0) . ")";
$departmentObject->checked = true;
} else {
$departmentObject->checked = false;
}
if ($department["HAS_CHILDREN"] == 1) {
$departmentObject->children = lookForChildrenDeps($department["DEP_DN"]);
}
$departmentObject->id = urlencode($department["DEP_DN"]);
$departmentsObjects[] = $departmentObject;
}
return $departmentsObjects;
}
function getDepartmentsWithDN()
{
$arrayDepartmentLdapDn = array();
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(DepartmentPeer::DEP_LDAP_DN);
$criteria->add(DepartmentPeer::DEP_LDAP_DN, "", Criteria::NOT_EQUAL);
$criteria->add(DepartmentPeer::DEP_LDAP_DN, null, Criteria::ISNOTNULL);
$rsCriteria = DepartmentPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayDepartmentLdapDn[] = $row;
}
return $arrayDepartmentLdapDn;
}
function getDepartmentsToUncheck($depsToCheck)
{
$departmentsWithDN = getDepartmentsWithDN();
$depsToUncheck = array();
foreach ($departmentsWithDN as $departmentWithDN) {
$found = false;
foreach ($depsToCheck as $depToCheck) {
if ($departmentWithDN["DEP_LDAP_DN"] == $depToCheck) {
$found = true;
}
}
if (!$found) {
$depsToUncheck[] = $departmentWithDN["DEP_LDAP_DN"];
}
}
return $depsToUncheck;
}
function getGroups()
{
global $groups;
$currentGroups = array();
foreach ($groups as $key => $val) {
$node = array();
$node["GRP_UID"] = $val["cn"];
$node["GRP_TITLE"] = $val["cn"];
$node["GRP_USERS"] = $val["users"];
$node["GRP_DN"] = $val["dn"];
$currentGroups[] = $node;
}
return $currentGroups;
}
function lookForChildrenGroups()
{
global $ldapAdvanced;
global $groups;
$allGroups = getGroups();
$groupsObjects = array();
$arrayGroupNumberOfUsersFromDb = $ldapAdvanced->groupsGetNumberOfUsersFromDb();
foreach ($allGroups as $group) {
$groupObject = new treeNode();
$groupObject->text = htmlentities($group["GRP_TITLE"], ENT_QUOTES, "UTF-8");
$groupUid = $ldapAdvanced->getGrpUidIfExistsDN($group["GRP_DN"]);
if ($groupUid != "") {
$groupObject->text .= " (" . ((isset($arrayGroupNumberOfUsersFromDb[$groupUid])) ? $arrayGroupNumberOfUsersFromDb[$groupUid] : 0) . ")";
$groupObject->checked = true;
} else {
$groupObject->checked = false;
}
$groupObject->id = urlencode($group["GRP_DN"]);
$groupsObjects[] = $groupObject;
}
return $groupsObjects;
}
function getGroupsWithDN()
{
$groupInstance = new Groupwf();
$allGroups = $groupInstance->getAll()->data;
$groupsWithDN = array();
foreach ($allGroups as $group) {
if ($group["GRP_LDAP_DN"] != "") {
$groupsWithDN[] = $group;
}
}
return $groupsWithDN;
}
function getGroupsToUncheck($groupsToCheck)
{
$groupsWithDN = getGroupsWithDN();
$groupsToUncheck = array();
foreach ($groupsWithDN as $groupWithDN) {
$found = false;
foreach ($groupsToCheck as $groupToCheck) {
if ($groupWithDN["GRP_LDAP_DN"] == $groupToCheck) {
$found = true;
}
}
if (!$found) {
$groupsToUncheck[] = $groupWithDN["GRP_LDAP_DN"];
}
}
return $groupsToUncheck;
}
function custom_ldap_explode_dn($dn)
{
$result = ldap_explode_dn($dn, 0);
unset($result["count"]);
foreach ($result as $key => $value) {
$result[$key] = addcslashes(preg_replace_callback("/\\\([0-9A-Fa-f]{2})/", function ($m) {
return chr(hexdec($m[1]));
}, $value), '<>,"');
}
return $result;
}

View File

@@ -1,236 +0,0 @@
<?php
/**
* authSources_Ajax.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
use ProcessMaker\Plugins\PluginRegistry;
try {
global $RBAC;
if ($RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
}
switch ($_REQUEST['action']) {
case 'searchUsers':
$criteria = new Criteria( 'workflow' );
$criteria->addSelectColumn( UsersPeer::USR_USERNAME );
$criteria->add( UsersPeer::USR_STATUS, array ('CLOSED'
), Criteria::NOT_IN );
$dataset = UsersPeer::DoSelectRs( $criteria );
$dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$dataset->next();
$pmUsers = array ();
while ($row = $dataset->getRow()) {
$pmUsers[] = $row['USR_USERNAME'];
$dataset->next();
}
$aFields = $RBAC->getAuthSource( $_POST['sUID'] );
//$oJSON = new Services_JSON();
$i = 0;
$oUser = new Users();
$aAux = $RBAC->searchUsers( $_POST['sUID'], $_POST['sKeyword'] );
$aUsers = array ();
// note added by gustavo cruz gustavo-at-colosa.com
// changed the user data showed to accept FirstName and LastName variables
$aUsers[] = array ('Checkbox' => 'char','Username' => 'char','FullName' => 'char','FirstName' => 'char','LastName' => 'char','Email' => 'char','DistinguishedName' => 'char'
);
foreach ($aAux as $aUser) {
if (! in_array( $aUser['sUsername'], $pmUsers )) {
// add replace to change D'Souza to D*Souza by krlos
$sCheckbox = '<div align="center"><input type="checkbox" name="aUsers[' . $i . ']" id="aUsers[' . $i . ']" value=\'' . str_replace( "\'", "*", addslashes( Bootstrap::json_encode( $aUser ) ) ) . '\' /></div>';
$i ++;
} else {
$sCheckbox = G::LoadTranslation( 'ID_USER_REGISTERED' ) . ':<br />(' . $aUser['sUsername'] . ')';
}
// note added by gustavo cruz gustavo-at-colosa.com
// assign the user data to the DBArray variable.
$aUsers[] = array ('Checkbox' => $sCheckbox,'Username' => $aUser['sUsername'],'FullName' => $aUser['sFullname'],'FirstName' => $aUser['sFirstname'],'LastName' => $aUser['sLastname'],'Email' => $aUser['sEmail'],'DistinguishedName' => $aUser['sDN']
);
}
global $_DBArray;
$_DBArray['users'] = $aUsers;
$_SESSION['_DBArray'] = $_DBArray;
$oCriteria = new Criteria( 'dbarray' );
$oCriteria->setDBArrayTable( 'users' );
$aData = Array ('Checkbox' => '0','FullName' => '0'
);
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
if ($aFields['AUTH_SOURCE_PROVIDER'] != 'ldap') {
$G_PUBLISH->AddContent( 'propeltable', 'pagedTableLdap', 'authSources/ldapSearchResults', $oCriteria, ' ', array ('Checkbox' => G::LoadTranslation( 'ID_MSG_CONFIRM_DELETE_CASE_SCHEDULER' )
) );
} else {
if (file_exists( PATH_XMLFORM . 'authSources/' . $aFields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' )) {
$G_PUBLISH->AddContent( 'propeltable', 'pagedTableLdap', 'authSources/' . $aFields['AUTH_SOURCE_PROVIDER'] . 'SearchResults', $oCriteria, ' ', array ('Checkbox' => G::LoadTranslation( 'ID_MSG_CONFIRM_DELETE_CASE_SCHEDULER' )
) );
} else {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', array ('MESSAGE' => 'File: ' . $aFields['AUTH_SOURCE_PROVIDER'] . 'SearchResults.xml' . ' doesn\'t exist.'
) );
}
}
G::RenderPage( 'publish', 'raw' );
break;
case 'authSourcesList':
global $RBAC;
$co = new Configurations();
$config = $co->getConfiguration('authSourcesList', 'pageSize', '', $_SESSION['USER_LOGGED']);
$limit_size = isset($config['pageSize']) ? $config['pageSize'] : 20;
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $limit_size;
$filter = isset($_REQUEST['textFilter']) ? $_REQUEST['textFilter'] : '';
$criterias = $RBAC->getAuthenticationSources($start, $limit, $filter);
$dataSourceAuthentication = AuthenticationSourcePeer::doSelectRS($criterias['COUNTER']);
$dataSourceAuthentication->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataSourceAuthentication->next();
$row = $dataSourceAuthentication->getRow();
$total_sources = $row['CNT'];
if (!empty($_REQUEST['orderBy']) && isset($_REQUEST['ascending']) && defined("AuthenticationSourcePeer::" . $_REQUEST['orderBy'])) {
if ($_REQUEST['ascending'] === '1') {
$criterias['LIST']->addAscendingOrderByColumn(constant("AuthenticationSourcePeer::" . $_REQUEST['orderBy']));
}
if ($_REQUEST['ascending'] === '0') {
$criterias['LIST']->addDescendingOrderByColumn(constant("AuthenticationSourcePeer::" . $_REQUEST['orderBy']));
}
} else {
$criterias['LIST']->addAscendingOrderByColumn(AuthenticationSourcePeer::AUTH_SOURCE_NAME);
}
$dataset = AuthenticationSourcePeer::doSelectRS($criterias['LIST']);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
global $RBAC;
$auth = $RBAC->getAllUsersByAuthSource();
$sources = [];
while ($dataset->next()) {
$row = $dataset->getRow();
$values = explode("_", $row["AUTH_SOURCE_PASSWORD"]);
foreach ($values as $value) {
if ($value == "2NnV3ujj3w") {
$row["AUTH_SOURCE_PASSWORD"] = G::decrypt($values[0], $row["AUTH_SOURCE_SERVER_NAME"]);
}
}
$label = G::LoadTranslation('ID_DISABLE');
if ($row['AUTH_SOURCE_ENABLED_TLS'] === "1") {
$label = G::LoadTranslation('ID_ENABLE');
}
$row['AUTH_SOURCE_ENABLED_TLS_LABEL'] = $label;
//additional information
$authSourceData = unserialize($row['AUTH_SOURCE_DATA']);
if (is_array($authSourceData)) {
$row = array_merge($row, $authSourceData);
}
$sources[] = $row;
$index = sizeof($sources) - 1;
$sources[$index]['CURRENT_USERS'] = isset($auth[$sources[$index]['AUTH_SOURCE_UID']]) ? $auth[$sources[$index]['AUTH_SOURCE_UID']] : 0;
}
$response = [
'sources' => $sources,
'total_sources' => $total_sources
];
echo G::json_encode($response);
break;
case 'canDeleteAuthSource':
try {
$authUID = $_POST['auth_uid'];
global $RBAC;
$aAuth = $RBAC->getAllUsersByAuthSource();
$response = isset( $aAuth[$authUID] ) ? 'false' : 'true';
echo '{success: ' . $response . '}';
} catch (Exception $ex) {
$token = strtotime("now");
PMException::registerErrorLog($ex, $token);
$varRes = '{success: false, error: ' . G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) . '}';
G::outRes( $varRes );
}
break;
case 'deleteAuthSource':
try {
global $RBAC;
$RBAC->removeAuthSource( $_POST['auth_uid'] );
echo '{success: true}';
} catch (Exception $ex) {
$token = strtotime("now");
PMException::registerErrorLog($ex, $token);
$varRes = '{success: false, error: ' . G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) . '}';
G::outRes( $varRes );
}
break;
case 'authSourcesNew':
$pluginRegistry = PluginRegistry::loadSingleton();
$arr = Array ();
$oDirectory = dir( PATH_RBAC . 'plugins' . PATH_SEP );
while ($sObject = $oDirectory->read()) {
if (($sObject != '.') && ($sObject != '..') && ($sObject != '.svn') && ($sObject != 'ldap')) {
if (is_file( PATH_RBAC . 'plugins' . PATH_SEP . $sObject )) {
$sType = trim(str_replace(array("class.", ".php"), "", $sObject));
// Filter Authentication Sources added by plugins, because these will be configured from another place
if ($sType != "ldapAdvanced" && $sType != "Gauth") {
$arr[] = array("sType" => $sType, "sLabel" => $sType);
}
}
}
}
$arr[] = array("sType" => "ldapAdvanced", "sLabel" => "ldapAdvanced");
echo '{sources: ' . G::json_encode( $arr ) . '}';
break;
case 'loadauthSourceData':
global $RBAC;
$fields = $RBAC->getAuthSource( $_POST['sUID'] );
if (is_array( $fields['AUTH_SOURCE_DATA'] )) {
foreach ($fields['AUTH_SOURCE_DATA'] as $field => $value) {
$fields[$field] = $value;
}
}
unset( $fields['AUTH_SOURCE_DATA'] );
$result = new stdclass();
$result->success = true;
$result->sources = $fields;
print (G::json_encode( $result )) ;
break;
}
} catch (Exception $e) {
$fields = array ('MESSAGE' => $e->getMessage()
);
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $fields );
G::RenderPage( 'publish', 'blank' );
}

View File

@@ -1,32 +0,0 @@
<?php
/**
* authSources_Delete.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
global $RBAC;
if ($RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
}
$RBAC->removeAuthSource( $_POST['AUTH_SOURCE_UID'] );

View File

@@ -1,103 +0,0 @@
<?php
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
return;
}
if (!isset($_GET['sUID'])) {
G::SendTemporalMessage('ID_ERROR_OBJECT_NOT_EXISTS', 'error', 'labels');
G::header('location: authSources_List');
return;
}
if ($_GET['sUID'] == '') {
G::SendTemporalMessage('ID_ERROR_OBJECT_NOT_EXISTS', 'error', 'labels');
G::header('location: authSources_List');
return;
}
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$fields = $RBAC->getAuthSource($_GET['sUID']);
if (is_array($fields['AUTH_SOURCE_DATA'])) {
foreach ($fields['AUTH_SOURCE_DATA'] as $field => $value) {
$fields[$field] = $value;
}
}
$fields['AUTH_SOURCE_SHOWGRID_FLAG'] = 0;
if (isset($fields['AUTH_SOURCE_DATA']['AUTH_SOURCE_SHOWGRID']) && $fields['AUTH_SOURCE_DATA']['AUTH_SOURCE_SHOWGRID'] == 'on') {
$fields["AUTH_SOURCE_SHOWGRID_FLAG"] = 1;
}
unset($fields['AUTH_SOURCE_DATA']);
$textAttribute = '';
if (isset($fields['AUTH_SOURCE_GRID_ATTRIBUTE']) && count($fields['AUTH_SOURCE_GRID_ATTRIBUTE'])) {
foreach ($fields['AUTH_SOURCE_GRID_ATTRIBUTE'] as $value) {
$textAttribute .= '|' . $value['attributeLdap'] . '/' . $value['attributeUser'];
}
}
$fields['AUTH_SOURCE_GRID_TEXT'] = $textAttribute;
//fixing a problem with dropdown with int values,
//the problem : the value was integer, but the dropdown was expecting a string value, and they returns always the first item of dropdown
if (isset($fields['AUTH_SOURCE_ENABLED_TLS'])) {
$fields['AUTH_SOURCE_ENABLED_TLS'] = sprintf('%d', $fields['AUTH_SOURCE_ENABLED_TLS']);
}
if (isset($fields['AUTH_ANONYMOUS'])) {
$fields['AUTH_ANONYMOUS'] = sprintf('%d', $fields['AUTH_ANONYMOUS']);
}
$G_PUBLISH = new Publisher();
if ($fields['AUTH_SOURCE_PROVIDER'] == 'ldap') {
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('authSources/authSourcesEdit', false);
$oHeadPublisher->assign('sUID', $_GET['sUID']);
G::RenderPage('publish', 'extJs');
} else {
if (file_exists(PATH_XMLFORM . 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
$pluginEnabled = 1;
if ($pluginEnabled == 1) {
$data = executeQuery("DESCRIBE USERS");
$fieldSet = ["USR_ID", "USR_UID", "USR_USERNAME", "USR_PASSWORD", "USR_CREATE_DATE", "USR_UPDATE_DATE", "USR_COUNTRY", "USR_CITY", "USR_LOCATION", "DEP_UID", "USR_RESUME", "USR_ROLE", "USR_REPORTS_TO", "USR_REPLACED_BY", "USR_UX"];
$attributes = null;
foreach ($data as $value) {
if (!(in_array($value["Field"], $fieldSet))) {
$attributes = $attributes . $value["Field"] . "|";
}
}
$fields["AUTH_SOURCE_ATTRIBUTE_IDS"] = $attributes;
if (file_exists(PATH_XMLFORM . 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Flag')) {
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->assign("Fields", $fields);
$oHeadPublisher->addExtJsScript(PATH_TPL . 'ldapAdvanced/library', false, true);
$oHeadPublisher->addExtJsScript(PATH_TPL . 'ldapAdvanced/ldapAdvancedForm', false, true);
$oHeadPublisher->addExtJsScript(PATH_TPL . 'ldapAdvanced/ldapAdvancedList', false, true);
G::RenderPage('publish', 'extJs');
return;
}
$G_PUBLISH->AddContent("xmlform", "xmlform", 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $fields, '../authSources/authSources_Save');
} else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', ['MESSAGE' => G::LoadTranslation('ID_AUTH_SOURCE_MISSING')]);
}
} else {
if (file_exists(PATH_XMLFORM . 'authSources/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $fields, '../authSources/authSources_Save');
} else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', ['MESSAGE' => 'File: ' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' . ' not exists.']);
}
}
G::RenderPage("publish", "blank");
}

View File

@@ -1,107 +0,0 @@
<?php
/**
* authSources_ImportUsers.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
global $RBAC;
if ($RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
}
$aFields = $RBAC->getAuthSource( $_POST['form']['AUTH_SOURCE_UID'] );
$aAttributes = array();
if (isset($aFields['AUTH_SOURCE_DATA']['AUTH_SOURCE_GRID_ATTRIBUTE'])) {
$aAttributes = $aFields['AUTH_SOURCE_DATA']['AUTH_SOURCE_GRID_ATTRIBUTE'];
}
//$oJSON = new Services_JSON();
foreach ($_POST['aUsers'] as $sUser) {
$matches = array ();
$aUser = (array) Bootstrap::json_decode( stripslashes( $sUser ) );
$aData['USR_USERNAME'] = str_replace( "*", "'", $aUser['sUsername'] );
$aData['USR_PASSWORD'] = G::encryptOld( str_replace( "*", "'", $aUser['sUsername'] ) );
// note added by gustavo gustavo-at-colosa.com
// asign the FirstName and LastName variables
// add replace to change D*Souza to D'Souza by krlos
$aData['USR_FIRSTNAME'] = str_replace( "*", "'", $aUser['sFirstname'] );
$aData['USR_LASTNAME'] = str_replace( "*", "'", $aUser['sLastname'] );
$aData['USR_EMAIL'] = $aUser['sEmail'];
$aData['USR_DUE_DATE'] = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) + 2 ) );
$aData['USR_CREATE_DATE'] = date( 'Y-m-d H:i:s' );
$aData['USR_UPDATE_DATE'] = date( 'Y-m-d H:i:s' );
$aData['USR_BIRTHDAY'] = date( 'Y-m-d' );
$aData['USR_STATUS'] = 1;
$aData['USR_AUTH_TYPE'] = strtolower( $aFields['AUTH_SOURCE_PROVIDER'] );
$aData['UID_AUTH_SOURCE'] = $aFields['AUTH_SOURCE_UID'];
// validating with regexp if there are some missing * inside the DN string
// if it's so the is changed to the ' character
preg_match( '/[a-zA-Z]\*[a-zA-Z]/', $aUser['sDN'], $matches );
foreach ($matches as $key => $match) {
$newMatch = str_replace( '*', '\'', $match );
$aUser['sDN'] = str_replace( $match, $newMatch, $aUser['sDN'] );
}
$aData['USR_AUTH_USER_DN'] = $aUser['sDN'];
try {
$sUserUID = $RBAC->createUser( $aData, 'PROCESSMAKER_OPERATOR' );
} catch(Exception $oError) {
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', array ('MESSAGE' => $oError->getMessage()) );
G::RenderPage("publish", "blank");
die();
}
$aData['USR_STATUS'] = 'ACTIVE';
$aData['USR_UID'] = $sUserUID;
$aData['USR_PASSWORD'] = G::encryptOld( $sUserUID ); //fake :p
$aData['USR_ROLE'] = 'PROCESSMAKER_OPERATOR';
if (count($aAttributes)) {
foreach ($aAttributes as $value) {
if (isset($aUser[$value['attributeUser']])) {
$aData[$value['attributeUser']] = str_replace( "*", "'", $aUser[$value['attributeUser']] );
if ($value['attributeUser'] == 'USR_STATUS') {
$evalValue = $aData[$value['attributeUser']];
$statusValue = 'INACTIVE';
if (is_string($evalValue) && G::toUpper($evalValue) == 'ACTIVE') {
$statusValue = 'ACTIVE';
}
if (is_bool($evalValue) && $evalValue == true) {
$statusValue = 'ACTIVE';
}
if ( (is_float($evalValue) || is_int($evalValue) ||
is_integer($evalValue) || is_numeric($evalValue)) && (int)$evalValue != 0) {
$statusValue = 'ACTIVE';
}
$aData[$value['attributeUser']] = $statusValue;
}
}
}
}
$oUser = new Users();
$oUser->create( $aData );
}
G::header( 'Location: ../users/users_List' );

View File

@@ -1,48 +0,0 @@
<?php
/**
* authSources_List.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die();
}
$c = new Configurations();
$configPage = $c->getConfiguration('authSourcesList', 'pageSize', '', $_SESSION['USER_LOGGED']);
$Config['pageSize'] = isset($configPage['pageSize']) ? $configPage['pageSize'] : 20;
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$G_PUBLISH = new Publisher();
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('authSources/authSourcesList', false); //adding a javascript file .js
$oHeadPublisher->addExtJsScript('authSources/authSourcesListSyn', false); //adding a javascript file .js
$oHeadPublisher->addContent('authSources/authSourcesList'); //adding a html file .html.
$oHeadPublisher->assign('FORMATS', $c->getFormats());
$oHeadPublisher->assign('CONFIG', $Config);
G::RenderPage('publish', 'extJs');

View File

@@ -1,56 +0,0 @@
<?php
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
return;
}
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$fields = ['AUTH_SOURCE_PROVIDER' => $_REQUEST['AUTH_SOURCE_PROVIDER']];
$G_PUBLISH = new Publisher();
if (file_exists(PATH_XMLFORM . 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
$pluginEnabled = 1;
if ($pluginEnabled == 1) {
//The attributes the users
$data = executeQuery("DESCRIBE USERS");
$fieldSet = ["USR_ID", "USR_UID", "USR_USERNAME", "USR_PASSWORD", "USR_CREATE_DATE", "USR_UPDATE_DATE", "USR_COUNTRY", "USR_CITY", "USR_LOCATION", "DEP_UID", "USR_RESUME", "USR_ROLE", "USR_REPORTS_TO", "USR_REPLACED_BY", "USR_UX"];
$attributes = null;
foreach ($data as $value) {
if (!(in_array($value["Field"], $fieldSet))) {
$attributes = $attributes . $value["Field"] . "|";
}
}
$fields["AUTH_SOURCE_ATTRIBUTE_IDS"] = $attributes;
if (file_exists(PATH_XMLFORM . 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Flag')) {
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->assign("Fields", $fields);
$oHeadPublisher->addExtJsScript(PATH_TPL . 'ldapAdvanced/library', false, true);
$oHeadPublisher->addExtJsScript(PATH_TPL . 'ldapAdvanced/ldapAdvancedForm', false, true);
$oHeadPublisher->addExtJsScript(PATH_TPL . 'ldapAdvanced/ldapAdvancedList', false, true);
G::RenderPage('publish', 'extJs');
return;
}
$G_PUBLISH->AddContent("xmlform", "xmlform", 'ldapAdvanced/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $fields, '../authSources/authSources_Save');
} else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', ['MESSAGE' => G::LoadTranslation('ID_AUTH_SOURCE_MISSING')]);
}
} else {
if (file_exists(PATH_XMLFORM . 'authSources/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml')) {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'authSources/' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit', '', $fields, '../authSources/authSources_Save');
} else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', ['MESSAGE' => 'File: ' . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' . ' not exists.']);
}
}
G::RenderPage("publish", "blank");

View File

@@ -1,60 +0,0 @@
<?php
/**
* authSources_Save.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
global $RBAC;
if ($RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
G::header( 'location: ../login/login' );
die();
}
unset( $_POST['form']['btnSave'] );
$aCommonFields = array ('AUTH_SOURCE_UID','AUTH_SOURCE_NAME','AUTH_SOURCE_PROVIDER','AUTH_SOURCE_SERVER_NAME','AUTH_SOURCE_PORT','AUTH_SOURCE_ENABLED_TLS','AUTH_ANONYMOUS','AUTH_SOURCE_SEARCH_USER','AUTH_SOURCE_PASSWORD','AUTH_SOURCE_VERSION','AUTH_SOURCE_BASE_DN','AUTH_SOURCE_OBJECT_CLASSES','AUTH_SOURCE_ATTRIBUTES');
$aFields = $aData = array ();
foreach ($_POST['form'] as $sField => $sValue) {
if (in_array( $sField, $aCommonFields )) {
$aFields[$sField] = $sValue;
} else {
$aData[$sField] = $sValue;
}
}
unset($aData['AUTH_SOURCE_ATTRIBUTE_IDS']);
unset($aData['AUTH_SOURCE_SHOWGRID_FLAG']);
unset($aData['AUTH_SOURCE_GRID_TEXT']);
if (!isset($aData['AUTH_SOURCE_SHOWGRID']) || $aData['AUTH_SOURCE_SHOWGRID'] == 'off') {
unset($aData['AUTH_SOURCE_GRID_ATTRIBUTE']);
}
$aFields['AUTH_SOURCE_DATA'] = $aData;
if ($aFields['AUTH_SOURCE_UID'] == '') {
$RBAC->createAuthSource( $aFields );
} else {
$RBAC->updateAuthSource( $aFields );
}
G::header( 'location: authSources_List' );

View File

@@ -1,53 +0,0 @@
<?php
/**
* authSources_SelectType.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die();
}
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$aAuthSourceTypes = array(array('sType' => 'char','sLabel' => 'char'));
$oDirectory = dir(PATH_RBAC . 'plugins' . PATH_SEP);
while ($sObject = $oDirectory->read()) {
if (($sObject != '.') && ($sObject != '..') && ($sObject != '.svn') && ($sObject != 'ldap')) {
if (is_file(PATH_RBAC . 'plugins' . PATH_SEP . $sObject)) {
$sType = trim(str_replace('class.', '', str_replace('.php', '', $sObject)));
$aAuthSourceTypes[] = array('sType' => $sType,'sLabel' => $sType );
}
}
}
global $_DBArray;
$_DBArray['authSourceTypes'] = $aAuthSourceTypes;
$_SESSION['_DBArray'] = $_DBArray;
$G_PUBLISH = new Publisher();
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('authSources/authSourcesListNew', true); //adding a javascript file .js
G::RenderPage('publish', 'extJs');

View File

@@ -1,41 +0,0 @@
<?php
/**
* authSources_SelectType.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2011 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
global $RBAC;
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') != 1) {
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
G::header('location: ../login/login');
die();
}
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'users';
$G_ID_MENU_SELECTED = 'USERS';
$G_ID_SUB_MENU_SELECTED = 'AUTH_SOURCES';
$aAuthSourceTypes = array(array('sType' => 'char','sLabel' => 'char'));
$oDirectory = dir(PATH_RBAC . 'plugins' . PATH_SEP);
$G_PUBLISH = new Publisher();
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->addExtJsScript('authSources/authSourceskindof', true); //adding a javascript file .js
$oHeadPublisher->assign('sprovider', $_GET['sprovider']);
G::RenderPage('publish', 'extJs');

View File

@@ -1,420 +0,0 @@
<?php
use ProcessMaker\Model\RbacAuthenticationSource;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
$function = $_REQUEST['functionAccion'];
switch ($function) {
case "ldapVerifyIfExistsRecordsInDb":
$response = array();
try {
$authenticationSourceUid = $_POST["authenticationSourceUid"];
$arrayAuthenticationSourceData = $RBAC->getAuthSource($authenticationSourceUid);
$flagUser = false;
$flagDepartment = false;
$flagGroup = false;
//Users
$criteria = new Criteria("rbac");
$criteria->addSelectColumn(RbacUsersPeer::USR_UID);
$criteria->add(RbacUsersPeer::USR_AUTH_USER_DN, "%" . $arrayAuthenticationSourceData["AUTH_SOURCE_BASE_DN"], Criteria::LIKE);
$criteria->setOffset(0); //Start
$criteria->setLimit(1); //Limit
$rsCriteria = RbacUsersPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
$flagUser = true;
}
//Departments
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(DepartmentPeer::DEP_UID);
$criteria->add(DepartmentPeer::DEP_LDAP_DN, "%" . $arrayAuthenticationSourceData["AUTH_SOURCE_BASE_DN"], Criteria::LIKE);
$criteria->setOffset(0); //Start
$criteria->setLimit(1); //Limit
$rsCriteria = DepartmentPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
$flagDepartment = true;
}
//Groups
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(GroupwfPeer::GRP_UID);
$criteria->add(GroupwfPeer::GRP_LDAP_DN, "%" . $arrayAuthenticationSourceData["AUTH_SOURCE_BASE_DN"], Criteria::LIKE);
$criteria->setOffset(0); //Start
$criteria->setLimit(1); //Limit
$rsCriteria = GroupwfPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
$flagGroup = true;
}
//Response
$response["status"] = "OK";
$response["existsRecords"] = ($flagUser || $flagDepartment || $flagGroup) ? 1 : 0;
} catch (Exception $e) {
//Response
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
echo G::json_encode($response);
break;
case 'ldapGrid':
$data = array();
switch ($_REQUEST['tipo']) {
case 'crear':
$data = array('ID' => G::generateUniqueID());
break;
case 'read':
if (isset($_REQUEST['data']) && $_REQUEST['data'] != '') {
$dataValue = G::json_decode($_REQUEST['data']);
$data = array();
foreach ($dataValue as $value) {
$data[] = array(
'ID' => G::generateUniqueID(),
'ATTRIBUTE_LDAP' => $value->attributeLdap,
'ATTRIBUTE_USER' => $value->attributeUser
);
}
}
break;
default:
break;
}
echo G::json_encode(array('success' => true, 'data' => $data, 'message' => 'Created Quote', 'total' => count($data)));
break;
case 'ldapVerifyName':
$authSourceName = empty($_REQUEST['AUTH_SOURCE_NAME']) ? '' : $_REQUEST['AUTH_SOURCE_NAME'];
$authenticationSource = RbacAuthenticationSource::query()
->select(['AUTH_SOURCE_UID', 'AUTH_SOURCE_NAME'])
->where('AUTH_SOURCE_NAME', '=', $authSourceName)
->first();
$row = false;
$suggestName = "";
if (!empty($authenticationSource)) {
$row = $authenticationSource;
$lastAuthenticationSource = RbacAuthenticationSource::query()
->select(['AUTH_SOURCE_NAME'])
->where('AUTH_SOURCE_NAME', 'LIKE', "%{$authSourceName}%")
->orderBy('AUTH_SOURCE_NAME', 'desc')
->first();
if (!empty($lastAuthenticationSource)) {
$name = $lastAuthenticationSource->AUTH_SOURCE_NAME;
//get suggest name
$pieces = explode(" ", $name);
$last = array_pop($pieces);
$number = trim($last, "()");
if ("({$number})" === $last) {
$number = intval($number) + 1;
$suggestName = implode("", $pieces) . " ({$number})";
} else {
$suggestName = $name . " (1)";
}
}
}
echo G::json_encode([
'success' => true,
'row' => $row,
'suggestName' => $suggestName
]);
break;
case 'ldapSave':
if (isset($_POST['AUTH_SOURCE_SHOWGRID-checkbox'])) {
if ($_POST['AUTH_SOURCE_SHOWGRID-checkbox'] == 'on') {
$_POST['AUTH_SOURCE_SHOWGRID'] = 'on';
$attributes = G::json_decode($_POST['AUTH_SOURCE_GRID_TEXT']);
$con = 1;
foreach ($attributes as $value) {
$_POST['AUTH_SOURCE_GRID_ATTRIBUTE'][$con] = (array) $value;
$con++;
}
}
unset($_POST['AUTH_SOURCE_SHOWGRID-checkbox']);
}
if ($_POST['AUTH_ANONYMOUS'] == '1') {
$_POST['AUTH_SOURCE_SEARCH_USER'] = '';
$_POST['AUTH_SOURCE_PASSWORD'] = '';
}
if (isset($_POST['AUTH_SOURCE_GRID_TEXT'])) {
unset($_POST['AUTH_SOURCE_GRID_TEXT']);
}
if (isset($_POST['DELETE1'])) {
unset($_POST['DELETE1']);
}
if (isset($_POST['DELETE2'])) {
unset($_POST['DELETE2']);
}
if (isset($_POST['AUTH_SOURCE_ATTRIBUTE_IDS'])) {
unset($_POST['AUTH_SOURCE_ATTRIBUTE_IDS']);
}
if (isset($_POST['AUTH_SOURCE_SHOWGRID_FLAG'])) {
unset($_POST['AUTH_SOURCE_SHOWGRID_FLAG']);
}
if (isset($_POST['AUTH_SOURCE_GRID_TEXT'])) {
unset($_POST['AUTH_SOURCE_GRID_TEXT']);
}
$aCommonFields = array('AUTH_SOURCE_UID', 'AUTH_SOURCE_NAME', 'AUTH_SOURCE_PROVIDER', 'AUTH_SOURCE_SERVER_NAME', 'AUTH_SOURCE_PORT', 'AUTH_SOURCE_ENABLED_TLS', 'AUTH_ANONYMOUS', 'AUTH_SOURCE_SEARCH_USER', 'AUTH_SOURCE_PASSWORD', 'AUTH_SOURCE_VERSION', 'AUTH_SOURCE_BASE_DN', 'AUTH_SOURCE_OBJECT_CLASSES', 'AUTH_SOURCE_ATTRIBUTES');
$aFields = $aData = array();
foreach ($_POST as $sField => $sValue) {
if (in_array($sField, $aCommonFields)) {
$aFields[$sField] = $sValue;
} else {
$aData[$sField] = $sValue;
}
}
if (!isset($aData['AUTH_SOURCE_SHOWGRID']) || $aData['AUTH_SOURCE_SHOWGRID'] == 'off') {
unset($aData['AUTH_SOURCE_GRID_ATTRIBUTE']);
unset($aData['AUTH_SOURCE_SHOWGRID']);
}
$aFields['AUTH_SOURCE_DATA'] = $aData;
//LDAP_PAGE_SIZE_LIMIT
$ldapAdvanced = new LdapAdvanced();
try {
$arrayAuthenticationSourceData = $aFields;
$arrayAuthenticationSourceData['AUTH_SOURCE_VERSION'] = 3;
$aFields['AUTH_SOURCE_DATA']['LDAP_PAGE_SIZE_LIMIT'] = $ldapAdvanced->getPageSizeLimit(
$ldapAdvanced->ldapConnection($arrayAuthenticationSourceData),
$arrayAuthenticationSourceData['AUTH_SOURCE_BASE_DN']
);
} catch (Exception $e) {
$aFields['AUTH_SOURCE_DATA']['LDAP_PAGE_SIZE_LIMIT'] = $ldapAdvanced->getPageSizeLimit(false);
}
//Save
if ($aFields['AUTH_SOURCE_UID'] == '') {
$RBAC->createAuthSource($aFields);
} else {
$RBAC->updateAuthSource($aFields);
}
echo G::json_encode(array('success' => true));
break;
case "searchUsers":
$response = array();
try {
$pageSize = $_POST["pageSize"];
$authenticationSourceUid = $_POST["sUID"];
$keyword = $_POST["sKeyword"];
$start = (isset($_POST["start"])) ? $_POST["start"] : 0;
$limit = (isset($_POST["limit"])) ? $_POST["limit"] : $pageSize;
//Get Users from Database
$arrayUser = array();
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(UsersPeer::USR_USERNAME);
$criteria->addSelectColumn(RbacUsersPeer::UID_AUTH_SOURCE);
$criteria->addJoin(UsersPeer::USR_UID, RbacUsersPeer::USR_UID);
$criteria->add(UsersPeer::USR_STATUS, "CLOSED", Criteria::NOT_EQUAL);
$rsCriteria = UsersPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayUser[strtolower($row["USR_USERNAME"])] = $row['UID_AUTH_SOURCE'];
}
//Get data
$arrayData = array();
$ldapAdvanced = new LdapAdvanced();
$ldapAdvanced->sAuthSource = $authenticationSourceUid;
$result = $ldapAdvanced->searchUsers($keyword, $start, $limit);
foreach ($result["data"] as $value) {
$arrayUserData = $value;
if (!isset($arrayUser[strtolower($arrayUserData["sUsername"])])) {
$arrayUserData["STATUS"] = G::LoadTranslation("ID_NOT_IMPORTED");
$arrayUserData["IMPORT"] = 1;
} elseif ($authenticationSourceUid === $arrayUser[strtolower($arrayUserData["sUsername"])]) {
$arrayUserData["STATUS"] = G::LoadTranslation("ID_IMPORTED");
$arrayUserData["IMPORT"] = 0;
} else {
$arrayUserData["STATUS"] = G::LoadTranslation("ID_CANNOT_IMPORT");
$arrayUserData["IMPORT"] = 0;
}
$arrayData[] = $arrayUserData;
}
//Response
$response["status"] = "OK";
$response["success"] = true;
$response["resultTotal"] = $result["numRecTotal"];
$response["resultRoot"] = $arrayData;
} catch (Exception $e) {
//Response
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
echo G::json_encode($response);
break;
case 'importUsers':
$usersImport = $_REQUEST['UsersImport'];
$authSourceUid = $_REQUEST['AUTH_SOURCE_UID'];
$aUsers = G::json_decode($usersImport);
global $RBAC;
$aFields = $RBAC->getAuthSource($authSourceUid);
$aAttributes = array();
if (isset($aFields['AUTH_SOURCE_DATA']['AUTH_SOURCE_GRID_ATTRIBUTE'])) {
$aAttributes = $aFields['AUTH_SOURCE_DATA']['AUTH_SOURCE_GRID_ATTRIBUTE'];
}
$usersCreated = '';
$countUsers = 0;
//$usersImport
foreach ($aUsers as $sUser) {
$aUser = (array) $sUser;
$matches = array();
$aData = array();
$aData['USR_USERNAME'] = str_replace("*", "'", $aUser['sUsername']);
$aData["USR_PASSWORD"] = "00000000000000000000000000000000";
// note added by gustavo gustavo-at-colosa.com
// asign the FirstName and LastName variables
// add replace to change D*Souza to D'Souza by krlos
$aData['USR_FIRSTNAME'] = str_replace("*", "'", $aUser['sFirstname']);
$aData['USR_FIRSTNAME'] = ($aData['USR_FIRSTNAME'] == '') ? $aData['USR_USERNAME'] : $aData['USR_FIRSTNAME'];
$aData['USR_LASTNAME'] = str_replace("*", "'", $aUser['sLastname']);
$aData['USR_EMAIL'] = $aUser['sEmail'];
$aData['USR_DUE_DATE'] = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y') + 2));
$aData['USR_CREATE_DATE'] = date('Y-m-d H:i:s');
$aData['USR_UPDATE_DATE'] = date('Y-m-d H:i:s');
$aData['USR_BIRTHDAY'] = date('Y-m-d');
$aData['USR_STATUS'] = (isset($aUser['USR_STATUS'])) ? (($aUser['USR_STATUS'] == 'ACTIVE') ? 1 : 0) : 1;
$aData['USR_AUTH_TYPE'] = strtolower($aFields['AUTH_SOURCE_PROVIDER']);
$aData['UID_AUTH_SOURCE'] = $aFields['AUTH_SOURCE_UID'];
// validating with regexp if there are some missing * inside the DN string
// if it's so the is changed to the ' character
preg_match('/[a-zA-Z]\*[a-zA-Z]/', $aUser['sDN'], $matches);
foreach ($matches as $key => $match) {
$newMatch = str_replace('*', '\'', $match);
$aUser['sDN'] = str_replace($match, $newMatch, $aUser['sDN']);
}
$aData['USR_AUTH_USER_DN'] = $aUser['sDN'];
$usrRole = 'LURANA_OPERATOR';
if (!empty($aFields['AUTH_SOURCE_DATA']['USR_ROLE'])) {
//$usrRole = $aFields['AUTH_SOURCE_DATA']['USR_ROLE'];
}
try {
//dd($aData, $usrRole, $aFields['AUTH_SOURCE_NAME']);
$sUserUID = $RBAC->createUser($aData, $usrRole, $aFields['AUTH_SOURCE_NAME']);
$usersCreated .= $aData['USR_USERNAME'] . ' ';
$countUsers++;
} catch (Exception $oError) {
dd($oError);
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => $oError->getMessage()));
G::RenderPage("publish", "blank");
die();
}
$aData['USR_STATUS'] = (isset($aUser['USR_STATUS'])) ? $aUser['USR_STATUS'] : 'ACTIVE';
$aData['USR_UID'] = $sUserUID;
$aData['USR_ROLE'] = $usrRole;
$calendarObj = new Calendar();
$calendarObj->assignCalendarTo($sUserUID, '00000000000000000000000000000001', 'USER');
if (count($aAttributes)) {
foreach ($aAttributes as $value) {
if (isset($aUser[$value['attributeUser']])) {
$aData[$value['attributeUser']] = str_replace("*", "'", $aUser[$value['attributeUser']]);
if ($value['attributeUser'] == 'USR_STATUS') {
$evalValue = $aData[$value['attributeUser']];
$statusValue = $aData['USR_STATUS'];
$aData[$value['attributeUser']] = $statusValue;
}
}
}
}
$oUser = new Users();
$oUser->create($aData);
}
$sClassName = strtolower($aFields['AUTH_SOURCE_PROVIDER']);
$plugin = G::factory($sClassName);
$aAuthSource = $RBAC->authSourcesObj->load($authSourceUid);
if (is_null($plugin->ldapcnn)) {
$plugin->ldapcnn = $plugin->ldapConnection($aAuthSource);
}
$ldapcnn = $plugin->ldapcnn;
$plugin->log($ldapcnn, "Users imported $countUsers: " . $usersCreated);
echo G::json_encode(array('success' => true));
break;
case "ldapTestConnection":
$response = array();
try {
if ($_POST["AUTH_ANONYMOUS"] == "1") {
$_POST["AUTH_SOURCE_SEARCH_USER"] = "";
$_POST["AUTH_SOURCE_PASSWORD"] = "";
}
$arrayAuthenticationSourceData = $_POST;
$arrayAuthenticationSourceData['AUTH_SOURCE_VERSION'] = 3;
//Test connection
$ldapAdvanced = new LdapAdvanced();
$resultLDAPStartTLS = true;
$ldapcnn = $ldapAdvanced->ldapConnection($arrayAuthenticationSourceData, $resultLDAPStartTLS);
//Response
$response["status"] = "OK";
if ($resultLDAPStartTLS === false) {
$response["message"] = G::LoadTranslation("ID_TLS_CERTIFICATE_IS_NOT_INSTALLED_IN_THE_SERVER");
}
} catch (Exception $e) {
//Response
$response["status"] = "ERROR";
$response["message"] = $e->getMessage();
}
echo G::json_encode($response);
break;
default:
break;
}