Closed tfrancois closed 10 months ago
So, I have an automated test for setting an attribute on a person that doesn't have that attribute yet, and it works. It sounds like you might be trying to add a brand new attribute that isn't part of the schema for the class you're editing? When I try to do that, I get the error "Undefined Attribute Type". Is that what you see?
I don't know a lot about actually administering an AD server, but I think you have to create a new schema for a class that inherits the current class on your object, then add new attributes to that schema. Once the attributes exist in the schema and the object is re-classed to your subclass, you'd be able to use setAttribute successfully. I think it's outside the scope of setAttribute to do any of those steps for you.
I'm adding an automated test for setting an attribute with a number and pushing up a fix for it.
Thank you as always for your prompt and complete replies @wickning1. You were correct! I was attempting to add an attribute that wasn't defined in the schema and that is why I was getting the error. I'm going to close this issue as I think your response to both my issues are resolved based on your answers.
Currently, this library generates an error when a non-existing AD attribute is passed as part of the modification object to the setAttribute method. Orginally, according to the ldapjsv3 docs:
Not sure if this is actually the case. When I perform my own tests by changing the 'replace' operation in the setAttributes method in the library code (for suggestion as a PR), the condition still fails. Not sure what the solution is, but it appears as if unless all the attribute in the modification object already exists, the setAttributes method will fail with an error.
Also, if the attribute value is not a string - it also fails! I recommemd changing the code for this method to as follows: