BUG 9717 I add attributes to ldap

I add attributes to ldap
This commit is contained in:
Brayan Osmar Pereyra Suxo
2012-11-05 09:57:09 -04:00
parent 96ff96b3f6
commit fdf3807521
5 changed files with 62 additions and 22 deletions

View File

@@ -218,7 +218,6 @@ class RBAC
{
$result = - 1; //default return value,
foreach ($this->aRbacPlugins as $sClassName) {
$plugin = new $sClassName();
if (method_exists( $plugin, 'automaticRegister' )) {
@@ -283,8 +282,9 @@ class RBAC
$plugin = new $sClassName();
$plugin->sAuthSource = $aUserFields["UID_AUTH_SOURCE"];
$plugin->sSystem = $this->sSystem;
$bValidUser = $plugin->VerifyLogin( $aUserFields["USR_AUTH_USER_DN"], $strPass );
$bValidUser = false;
$bValidUser = $plugin->VerifyLogin( $aUserFields["USR_AUTH_USER_DN"], $strPass );
if ($bValidUser === true) {
return ($aUserFields['USR_UID']);
} else {
@@ -335,9 +335,9 @@ class RBAC
if (isset( $this->userObj->fields['USR_AUTH_TYPE'] )) {
$sAuthType = strtolower( $this->userObj->fields['USR_AUTH_TYPE'] );
}
//Hook for RBAC plugins
if ($sAuthType != "mysql" && $sAuthType != "") {
$res = $this->VerifyWithOtherAuthenticationSource( $sAuthType, $this->userObj->fields, $strPass );
return $res;
} else {

View File

@@ -46,7 +46,6 @@ try {
}
$aFields = $RBAC->getAuthSource( $_POST['sUID'] );
G::LoadThirdParty( 'pear/json', 'class.json' );
$oJSON = new Services_JSON();
$i = 0;

View File

@@ -53,8 +53,20 @@ if (is_array( $fields['AUTH_SOURCE_DATA'] )) {
$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'] )) {
@@ -73,6 +85,17 @@ if ($fields['AUTH_SOURCE_PROVIDER'] == 'ldap') {
} else {
if (file_exists( PATH_PLUGINS . $fields['AUTH_SOURCE_PROVIDER'] . PATH_SEP . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml' )) {
if (class_exists( $fields['AUTH_SOURCE_PROVIDER'] )) {
// The attributes the users
G::loadClass('pmFunctions');
$data = executeQuery('DESCRIBE USERS');
$fieldSet = array('USR_UID','USR_USERNAME','USR_ROLE','USR_REPLACED_BY','USR_UX');
$attributes = '';
foreach ($data as $value) {
if (!(in_array($value['Field'], $fieldSet))) {
$attributes .= $value['Field'] . '|';
}
}
$fields['AUTH_SOURCE_ATTRIBUTE_IDS'] = $attributes;
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', $fields['AUTH_SOURCE_PROVIDER'] . PATH_SEP . $fields['AUTH_SOURCE_PROVIDER'] . 'Edit.xml', '', $fields, '../authSources/authSources_Save' );
} else {
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', array ('MESSAGE' => G::LoadTranslation( 'ID_AUTH_SOURCE_MISSING' )

View File

@@ -27,8 +27,11 @@ if ($RBAC->userCanAccess( 'PM_SETUP_ADVANCE' ) != 1) {
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'];
}
G::LoadThirdParty( 'pear/json', 'class.json' );
$oJSON = new Services_JSON();
@@ -64,6 +67,14 @@ foreach ($_POST['aUsers'] as $sUser) {
$aData['USR_UID'] = $sUserUID;
$aData['USR_PASSWORD'] = md5( $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']] );
}
}
}
require_once 'classes/model/Users.php';
$oUser = new Users();
$oUser->create( $aData );

View File

@@ -41,6 +41,13 @@ foreach ($_POST['form'] as $sField => $sValue) {
$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'] == '') {