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

@@ -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();
@@ -38,9 +41,9 @@ foreach ($_POST['aUsers'] as $sUser) {
$aUser = (array) $oJSON->decode( stripslashes( $sUser ) );
$aData['USR_USERNAME'] = str_replace( "*", "'", $aUser['sUsername'] );
$aData['USR_PASSWORD'] = md5( 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
// 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'];
@@ -51,8 +54,8 @@ foreach ($_POST['aUsers'] as $sUser) {
$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
// 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 );
@@ -62,8 +65,16 @@ foreach ($_POST['aUsers'] as $sUser) {
$sUserUID = $RBAC->createUser( $aData, 'PROCESSMAKER_OPERATOR' );
$aData['USR_STATUS'] = 'ACTIVE';
$aData['USR_UID'] = $sUserUID;
$aData['USR_PASSWORD'] = md5( $sUserUID ); //fake :p
$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 );