Skip to content

Attribute tagging interferes with entry.Unmarshal #530

@JesseCoretta

Description

@JesseCoretta

Consider the following struct excerpt:

          Value  string `ldap:"attributeName"`
          CValue string `ldap:"c-attributeName"` // is COLLECTIVE

When processed through entry.Unmarshal, both COLLECTIVE and NON-COLLECTIVE values are unmarshaled as expected, assuming the attribute descriptors found within the search result(s) appear as shown in the configured struct tags.

However, in certain X.500/LDAP implementations, COLLECTIVE attributes are assigned the ;collective attribute tag in search results. In such cases, entry.Unmarshal fails to recognize attributes bearing this tag.

The work-around is simply:

          Value  string `ldap:"attributeName"`
          CValue string `ldap:"c-attributeName;collective"`  // replace the previous CValue definition with this one

In this case entry.Unmarshal recognizes the value and handles it appropriately.

Of course, the above "code edit" is likely not advisable in the real-world. In an ideal situation, the presence of either c-attributeName or c-attributeName;collective should produce the same unmarshaled results.

Feel free to ping me with any questions, thank you 😃

Jesse

EDIT: It is also worth mentioning that not all situations involving tags would apply to the above. For example, language tags:

givenName: Jesse
givenName;lang-jp: ジェシー

Even if they are essentially saying the same thing, the two values are in fact totally distinct. Requesting the tag, and not requesting the tag, would and should return differing results. Furthermore, the act of supporting multiple languages as shown above is entirely driven by the manner in which the directory was designed and is being governed/populated.

The ;collective scenario, however, is "DSA implementation specific" and is not something the user "chose to see": the software itself imposes this tag whether we wanted it or not.

Therefore, I would assume that IF a solution were to be implemented, it would be safest to limit its scope to the aforementioned ;collective use case specifically, but I could be wrong.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions