node-ldapjs icon indicating copy to clipboard operation
node-ldapjs copied to clipboard

Entry addition to LDAP instance is successful after timeout error in ldapjs

Open prashanthmadduri opened this issue 6 years ago • 5 comments

Hi Team,

We tried add method execution to add the object into Microsoft Active Directory with timeout attribute value set to 10 milliseconds and registered timeout event to capture the operation timeout error.

As per our observation the error object captured in timeout event has new object we are trying to add instead error details. The timeout error details is captured in add method call.

Also, apart from timeout error the ldapjs allowed the entry to add into MS AD. This means we have timeout error along with successful execution of entry addition.

Below is the code sample:

const ldap = require('ldapjs');
let settings = {
	url: 'ldap://myldapserver:389',
	timeout: 10,
	connectTimeout: 1000
}
let client = ldap.createClient(settings)
client.on('error', (err) => {
	console.log('*******************err', err)	
})
client.on('timeout', (err) => {//error details are not available here. Instead it is printing new object entry we are adding.
	console.log('*******************timeout err', err)
})
client.on('connectTimeout', (err) => {
	console.log('*******************connectTimeout err', err)
})
var dn = "cn=testComputer,ou=testou,DC=mytest,DC=com";
var data = {
    cn: 'testComputer',	
    objectClass: 'computer',
    description: 'This is test implementation hence this is test description.'	
  }  
client.bind('CN=admin,DC=mytest,DC=com', 'adminpassword', (err) => {
	if (err) {
		console.log('*******************client.bind err', err)//timeout error details available here. Here it is printing error details. However the addition of the object is successful.
	} else {
		console.log('bind is success')
		client.add(dn, data, function(err) {
			if (err) {
			console.log('*******************addNewEntry method err', err)
			}
		})
		client.on('timeout', (err) => {//error details not available here. Instead it is printing new object we are adding. 
			console.log('*******************addNewEntry method timeout err', err)
		})
	}
})

Error details below:

*******************timeout err BindRequest {
  messageID: 1,
  protocolOp: 96,
  controls: [],
  log: undefined,
  version: 3,
  name: 'CN=admin,DC=mytest,DC=com',
  authentication: 'Simple',
  credentials: 'adminpassword' }
*******************client.bind err { TimeoutError: request timeout (client interrupt)
    at Timeout.onRequestTimeout (D:\ImplementationCheck\node_modules\ldapjs\lib\client\client.js:1437:10)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
  lde_message: 'request timeout (client interrupt)',
  lde_dn: null }

Please let us know what would be the best value for timeout attribute and how to handle the error in case of operation timeout considering the error details in timeout event is not as expected.

Thank you.

prashanthmadduri avatar Sep 04 '19 07:09 prashanthmadduri

An operation timeout of 10ms seems really short. The default is Inifinity. I would try a higher value. Also, specify a logger with the level at "trace" and provide the redacted logs here.

Which version of the library are you using?

jsumners avatar Sep 04 '19 12:09 jsumners

Hi @jsumners,

The issue raised in #554 is for providing Standard LDAP error code. As per my understanding ldapjs is not providing LDAP standard error code in the error details. If we consider the case where user of the endpoint(Active Directory) have idea on the LDAP standard error codes and expecting it in the error details to identify what might be wrong with the execution then it will help.

prashanthmadduri avatar Sep 04 '19 13:09 prashanthmadduri

Hi @jsumners

Regarding #556, we are using V1.0.2 release of ldapjs for implementation. We will try with higher value and will comeback with logs.

Other issue is irrespective of timeout error it is allowing to add entry into Active Directory. Ideally in case of timeout error it should not allow entry addition.

Thank you.

prashanthmadduri avatar Sep 04 '19 13:09 prashanthmadduri

Hi @jsumners

Here, why nodejs is allowing to add entry into AD irrespective of timeout error. As per my understanding it should not allow add entry after timeout error.

prashanthmadduri avatar Sep 10 '19 06:09 prashanthmadduri

Without more information I cannot attempt to help. Redacted trace logs would be very useful.

jsumners avatar Sep 10 '19 11:09 jsumners

👋

On February 22, 2023, we released version 3 of this library. As a result, we are closing this issue/pull request.

Please see issue #839 for more information, including how to proceed if you feel this closure is in error.

jsumners avatar Feb 22 '23 19:02 jsumners