node-activedirectory
node-activedirectory copied to clipboard
TypeError
Hello im having the following issue when trying to retrive users of an AD group, i have confirmed the existence of AD groups
activedirectory\lib\activedirectory.js:578 Array.prototype.push.apply(result[rangeAttribute.attributeName], result[rangeAttribute.toString()]); ^
TypeError: CreateListFromArrayLike called on non-object at C:\server\nodejsProject\node_modules\activedirectory\lib\activedirectory.js:578:26 at Function..each..forEach (C:\server\nodejsProject\node_modules\underscore\underscore.js:186:9) at ActiveDirectory.parseRangeAttributes (C:\server\nodejsProject\node_modules\activedirectory\lib\activedirectory.js:575:5) at EventEmitter.onSearchEntry (C:\server\nodejsProject\node_modules\activedirectory\lib\activedirectory.js:421:26) at emitOne (events.js:116:13) at EventEmitter.emit (events.js:211:7) at sendResult (C:\server\nodejsProject\node_modules\ldapjs\lib\client\client.js:1389:22) at messageCallback (C:\server\nodejsProject\node_modules\ldapjs\lib\client\client.js:1411:14) at Parser.onMessage (C:\server\nodejsProject\node_modules\ldapjs\lib\client\client.js:1089:14) at emitOne (events.js:116:13) at Parser.emit (events.js:211:7) at Parser.write (C:\server\nodejsProject\node_modules\ldapjs\lib\messages\parser.js:111:8) at Socket.onData (C:\server\nodejsProject\node_modules\ldapjs\lib\client\client.js:1076:22) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12)
any idea whats wrong?
I got this error too, but I was able to get a workaround by changing
Array.prototype.push.apply
to
Array.prototype.push.call
BTW I have no idea what was happened. It was working fine until it unexpectedly stop working.
thanks @inkirby i hope this get pushed
In my case, it would be happened when there is only exactly 1,500 * N + 1
users in a group (like 1,501
, 3,001
, 4,501
).
Because result[rangeAttribute.toString()]
would return a String[]
, but when there is only one element, it would return String
.
Array.prototype.push.apply([], String)
would trigger this bug, and Array.prototype.push.call([], String)
wouldn't.
I try to change
Array.prototype.push.apply(result[rangeAttribute.attributeName], result[rangeAttribute.toString()]);
to
let array = result[rangeAttribute.attributeName];
let object = result[rangeAttribute.toString()];
if (typeof(object) === 'string') {
array.push(object);
} else {
Array.prototype.push.apply(array, object);
}
It works good for me.