@@ -148,10 +148,10 @@ export class BackendsService extends AbstractQueueProcessor {
148148 }
149149
150150 public async syncAllIdentities ( options ?: ExecuteJobOptions ) : Promise < any > {
151- const syncAllIdentities = ( await this . identitiesService . find < Identities > ( {
151+ const syncAllIdentities = await this . identitiesService . find < any > ( {
152152 state : IdentityState . TO_SYNC ,
153- } ) ) as unknown as Identities [ ] ;
154- const identities = syncAllIdentities . map ( ( identity : Identities ) => {
153+ } ) ;
154+ const identities = syncAllIdentities . map ( ( identity : any ) => {
155155 return {
156156 action : ActionType . IDENTITY_UPDATE ,
157157 identity,
@@ -164,6 +164,13 @@ export class BackendsService extends AbstractQueueProcessor {
164164
165165 const result = { } ;
166166 for ( const identity of identities ) {
167+ //convertion tableau employeeNumber
168+ if ( identity . identity . primaryEmployeeNumber !== null ) {
169+ identity . identity . employeeNumber = identity . identity . identityprimaryEmployeeNumber ;
170+ } else {
171+ //on prend la premiere pour envoyer une chaine et non un tableau pour la compatibilité ldap
172+ identity . identity . inetOrgPerson . employeeNumber = identity . identity . inetOrgPerson . employeeNumber [ 0 ] ;
173+ }
167174 try {
168175 this . logger . debug ( `Syncing identity ${ identity . identity . _id } ` ) ;
169176 const [ executedJob ] = await this . executeJob (
@@ -208,6 +215,9 @@ export class BackendsService extends AbstractQueueProcessor {
208215 // cas des fusion l employeeNumber doit etre celui de l identite primaire
209216 if ( identity . primaryEmployeeNumber !== null ) {
210217 identity . inetOrgPerson . employeeNumber = identity . primaryEmployeeNumber ;
218+ } else {
219+ //on prend la premiere pour envoyer une chaine et non un tableau pour la compatibilité ldap
220+ identity . inetOrgPerson . employeeNumber = identity . inetOrgPerson . employeeNumber [ 0 ] ;
211221 }
212222 identities . push ( {
213223 action : ActionType . IDENTITY_UPDATE ,
@@ -240,7 +250,13 @@ export class BackendsService extends AbstractQueueProcessor {
240250 if ( ! payload . length ) throw new BadRequestException ( 'No identities to disable' ) ;
241251
242252 for ( const key of payload ) {
243- const identity = await this . identitiesService . findById < Identities > ( key ) ;
253+ const identity = await this . identitiesService . findById < any > ( key ) ;
254+ if ( identity . primaryEmployeeNumber !== null ) {
255+ identity . inetOrgPerson . employeeNumber = identity . primaryEmployeeNumber ;
256+ } else {
257+ //on prend la premiere pour envoyer une chaine et non un tableau pour la compatibilité ldap
258+ identity . inetOrgPerson . employeeNumber = identity . inetOrgPerson . employeeNumber [ 0 ] ;
259+ }
244260 if ( ! identity . lastBackendSync ) {
245261 throw new BadRequestException ( {
246262 status : HttpStatus . BAD_REQUEST ,
@@ -283,14 +299,20 @@ export class BackendsService extends AbstractQueueProcessor {
283299 if ( ! payload . length ) throw new BadRequestException ( 'No identities to disable' ) ;
284300
285301 for ( const key of payload ) {
286- const identity = await this . identitiesService . findById < Identities > ( key ) ;
302+ const identity = await this . identitiesService . findById < any > ( key ) ;
287303 if ( ! identity . lastBackendSync ) {
288304 throw new BadRequestException ( {
289305 status : HttpStatus . BAD_REQUEST ,
290306 message : `Identity ${ key } has never been synched` ,
291307 identity,
292308 } ) ;
293309 }
310+ if ( identity . primaryEmployeeNumber !== null ) {
311+ identity . inetOrgPerson . employeeNumber = identity . primaryEmployeeNumber ;
312+ } else {
313+ //on prend la premiere pour envoyer une chaine et non un tableau pour la compatibilité ldap
314+ identity . inetOrgPerson . employeeNumber = identity . inetOrgPerson . employeeNumber [ 0 ] ;
315+ }
294316 identities . push ( {
295317 action : ActionType . IDENTITY_DISABLE ,
296318 identity,
@@ -326,7 +348,13 @@ export class BackendsService extends AbstractQueueProcessor {
326348 if ( ! payload . length ) throw new BadRequestException ( 'No identities to disable' ) ;
327349
328350 for ( const key of payload ) {
329- const identity = await this . identitiesService . findById < Identities > ( key ) ;
351+ const identity = await this . identitiesService . findById < any > ( key ) ;
352+ if ( identity . primaryEmployeeNumber !== null ) {
353+ identity . inetOrgPerson . employeeNumber = identity . primaryEmployeeNumber ;
354+ } else {
355+ //on prend la premiere pour envoyer une chaine et non un tableau pour la compatibilité ldap
356+ identity . inetOrgPerson . employeeNumber = identity . inetOrgPerson . employeeNumber [ 0 ] ;
357+ }
330358 if ( ! identity . lastBackendSync ) {
331359 throw new BadRequestException ( {
332360 status : HttpStatus . BAD_REQUEST ,
@@ -362,7 +390,7 @@ export class BackendsService extends AbstractQueueProcessor {
362390 public async activationIdentity ( payload : string , status : boolean , options ?: ExecuteJobOptions ) {
363391 let result = null ;
364392 if ( status === true ) {
365- result = await this . enableIdentities ( [ payload ] , options ) ;
393+ result = await this . enableIdentities ( [ payload ] , options ) ;
366394 } else {
367395 result = await this . disableIdentities ( [ payload ] , options ) ;
368396 }
@@ -384,7 +412,7 @@ export class BackendsService extends AbstractQueueProcessor {
384412 } ,
385413 {
386414 ...options ?. job ,
387- jobId : ( new Types . ObjectId ( ) ) . toHexString ( ) ,
415+ jobId : ( new Types . ObjectId ( ) ) . toHexString ( ) ,
388416 attempts : 1 ,
389417 } ,
390418 ) ;
0 commit comments