11import ldapjs from 'ldapjs' ;
2- import util from 'util' ;
32import { Log } from 'meteor/logging' ;
43
54// copied from https://github.com/ldapjs/node-ldapjs/blob/a113953e0d91211eb945d2a3952c84b7af6de41c/lib/filters/index.js#L167
@@ -40,7 +39,7 @@ export default class LDAP {
4039 Authentication_Password : this . constructor . settings_get ( 'LDAP_AUTHENTIFICATION_PASSWORD' ) ,
4140 Authentication_Fallback : this . constructor . settings_get ( 'LDAP_LOGIN_FALLBACK' ) ,
4241 BaseDN : this . constructor . settings_get ( 'LDAP_BASEDN' ) ,
43- Internal_Log_Level : this . constructor . settings_get ( 'INTERNAL_LOG_LEVEL' ) ,
42+ Internal_Log_Level : this . constructor . settings_get ( 'INTERNAL_LOG_LEVEL' ) , //this setting does not have any effect any more and should be deprecated
4443 User_Authentication : this . constructor . settings_get ( 'LDAP_USER_AUTHENTICATION' ) ,
4544 User_Authentication_Field : this . constructor . settings_get ( 'LDAP_USER_AUTHENTICATION_FIELD' ) ,
4645 User_Attributes : this . constructor . settings_get ( 'LDAP_USER_ATTRIBUTES' ) ,
@@ -102,15 +101,6 @@ export default class LDAP {
102101 reconnect : this . options . Reconnect ,
103102 } ;
104103
105- if ( this . options . Internal_Log_Level !== 'disabled' ) {
106- connectionOptions . log = new Bunyan ( {
107- name : 'ldapjs' ,
108- component : 'client' ,
109- stream : process . stderr ,
110- level : this . options . Internal_Log_Level ,
111- } ) ;
112- }
113-
114104 const tlsOptions = {
115105 rejectUnauthorized : this . options . reject_unauthorized ,
116106 } ;
@@ -137,15 +127,15 @@ export default class LDAP {
137127 connectionOptions . url = `ldap://${ connectionOptions . url } ` ;
138128 }
139129
140- Log . info ( ' Connecting' , connectionOptions . url ) ;
141- Log . debug ( `connectionOptions${ util . inspect ( connectionOptions ) } ` ) ;
130+ Log . info ( ` Connecting ${ connectionOptions . url } ` ) ;
131+ Log . debug ( `connectionOptions ${ JSON . stringify ( connectionOptions ) } ` ) ;
142132
143133 this . client = ldapjs . createClient ( connectionOptions ) ;
144134
145135 this . bindSync = Meteor . wrapAsync ( this . client . bind , this . client ) ;
146136
147137 this . client . on ( 'error' , ( error ) => {
148- Log . error ( ' connection' , error ) ;
138+ Log . error ( ` connection ${ error } ` ) ;
149139 if ( replied === false ) {
150140 replied = true ;
151141 callback ( error , null ) ;
@@ -168,11 +158,11 @@ export default class LDAP {
168158 tlsOptions . host = this . options . host ;
169159
170160 Log . info ( 'Starting TLS' ) ;
171- Log . debug ( ' tlsOptions' , tlsOptions ) ;
161+ Log . debug ( ` tlsOptions ${ JSON . stringify ( tlsOptions ) } ` ) ;
172162
173163 this . client . starttls ( tlsOptions , null , ( error , response ) => {
174164 if ( error ) {
175- Log . error ( ' TLS connection' , error ) ;
165+ Log . error ( ` TLS connection ${ JSON . stringify ( error ) } ` ) ;
176166 if ( replied === false ) {
177167 replied = true ;
178168 callback ( error , null ) ;
@@ -200,7 +190,7 @@ export default class LDAP {
200190
201191 setTimeout ( ( ) => {
202192 if ( replied === false ) {
203- Log . error ( ' connection time out' , connectionOptions . connectTimeout ) ;
193+ Log . error ( ` connection time out ${ connectionOptions . connectTimeout } ` ) ;
204194 replied = true ;
205195 callback ( new Error ( 'Timeout' ) ) ;
206196 }
@@ -251,7 +241,7 @@ export default class LDAP {
251241 userDn = `${ this . options . User_Authentication_Field } =${ username } ,${ this . options . BaseDN } ` ;
252242 }
253243
254- Log . info ( ' Binding with User' , userDn ) ;
244+ Log . info ( ` Binding with User ${ userDn } ` ) ;
255245
256246 this . bindSync ( userDn , password ) ;
257247 this . domainBinded = true ;
@@ -266,7 +256,7 @@ export default class LDAP {
266256 return ;
267257 }
268258
269- Log . info ( ' Binding UserDN' , this . options . Authentication_UserDN ) ;
259+ Log . info ( ` Binding UserDN ${ this . options . Authentication_UserDN } ` ) ;
270260
271261 this . bindSync ( this . options . Authentication_UserDN , this . options . Authentication_Password ) ;
272262 this . domainBinded = true ;
@@ -289,9 +279,9 @@ export default class LDAP {
289279 } ;
290280 }
291281
292- Log . info ( ' Searching user' , username ) ;
293- Log . debug ( ' searchOptions' , searchOptions ) ;
294- Log . debug ( ' BaseDN' , this . options . BaseDN ) ;
282+ Log . info ( ` Searching user ${ username } ` ) ;
283+ Log . debug ( ` searchOptions ${ searchOptions } ` ) ;
284+ Log . debug ( ` BaseDN ${ this . options . BaseDN } ` ) ;
295285
296286 if ( page ) {
297287 return this . searchAllPaged ( this . options . BaseDN , searchOptions , page ) ;
@@ -329,9 +319,9 @@ export default class LDAP {
329319 scope : 'sub' ,
330320 } ;
331321
332- Log . info ( ' Searching by id' , id ) ;
333- Log . debug ( ' search filter' , searchOptions . filter . toString ( ) ) ;
334- Log . debug ( ' BaseDN' , this . options . BaseDN ) ;
322+ Log . info ( ` Searching by id ${ id } ` ) ;
323+ Log . debug ( ` search filter ${ searchOptions . filter . toString ( ) } ` ) ;
324+ Log . debug ( ` BaseDN ${ this . options . BaseDN } ` ) ;
335325
336326 const result = this . searchAllSync ( this . options . BaseDN , searchOptions ) ;
337327
@@ -340,7 +330,7 @@ export default class LDAP {
340330 }
341331
342332 if ( result . length > 1 ) {
343- Log . error ( ' Search by id' , id , ' returned' , result . length , ' records' ) ;
333+ Log . error ( ` Search by id ${ id } returned ${ result . length } records` ) ;
344334 }
345335
346336 return result [ 0 ] ;
@@ -354,9 +344,9 @@ export default class LDAP {
354344 scope : this . options . User_Search_Scope || 'sub' ,
355345 } ;
356346
357- Log . info ( ' Searching user' , username ) ;
358- Log . debug ( ' searchOptions' , searchOptions ) ;
359- Log . debug ( ' BaseDN' , this . options . BaseDN ) ;
347+ Log . info ( ` Searching user ${ username } ` ) ;
348+ Log . debug ( ` searchOptions ${ searchOptions } ` ) ;
349+ Log . debug ( ` BaseDN ${ this . options . BaseDN } ` ) ;
360350
361351 const result = this . searchAllSync ( this . options . BaseDN , searchOptions ) ;
362352
@@ -365,7 +355,7 @@ export default class LDAP {
365355 }
366356
367357 if ( result . length > 1 ) {
368- Log . error ( ' Search by username' , username , ' returned' , result . length , ' records' ) ;
358+ Log . error ( ` Search by username ${ username } returned ${ result . length } records` ) ;
369359 }
370360
371361 return result [ 0 ] ;
@@ -396,7 +386,7 @@ export default class LDAP {
396386 scope : 'sub' ,
397387 } ;
398388
399- Log . debug ( ' Group list filter LDAP:' , searchOptions . filter ) ;
389+ Log . debug ( ` Group list filter LDAP: ${ searchOptions . filter } ` ) ;
400390
401391 const result = this . searchAllSync ( this . options . BaseDN , searchOptions ) ;
402392
@@ -444,7 +434,7 @@ export default class LDAP {
444434 scope : 'sub' ,
445435 } ;
446436
447- Log . debug ( ' Group filter LDAP:' , searchOptions . filter ) ;
437+ Log . debug ( ` Group filter LDAP: ${ searchOptions . filter } ` ) ;
448438
449439 const result = this . searchAllSync ( this . options . BaseDN , searchOptions ) ;
450440
@@ -576,24 +566,24 @@ export default class LDAP {
576566 } ) ;
577567
578568 res . on ( 'end' , ( ) => {
579- Log . info ( ' Search result count' , entries . length ) ;
569+ Log . info ( ` Search result count ${ entries . length } ` ) ;
580570 callback ( null , entries ) ;
581571 } ) ;
582572 } ) ;
583573 }
584574
585575 authSync ( dn , password ) {
586- Log . info ( ' Authenticating' , dn ) ;
576+ Log . info ( ` Authenticating ${ dn } ` ) ;
587577
588578 try {
589579 if ( password === '' ) {
590580 throw new Error ( 'Password is not provided' ) ;
591581 }
592582 this . bindSync ( dn , password ) ;
593- Log . info ( ' Authenticated' , dn ) ;
583+ Log . info ( ` Authenticated ${ dn } ` ) ;
594584 return true ;
595585 } catch ( error ) {
596- Log . info ( ' Not authenticated' , dn ) ;
586+ Log . info ( ` Not authenticated ${ dn } ` ) ;
597587 Log . debug ( 'error' , error ) ;
598588 return false ;
599589 }
0 commit comments