Skip to content

can't handle binary data #2

@huancz

Description

@huancz

testcase:

dn: cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com
objectGUID;binary:: x7HAMN/oRNyn4w==

shift() result:

{ type: 'record',
  dn: 'cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com',
  attributes:
   [ { attribute:
        { type: 'attribute',
          options: [ 'binary' ],
          attribute: 'objectGUID' },
       value: { type: 'value', value: 'DZ�0��Dܧ�' } } ] }

toObject doesn't make it any better:

{ dn: 'cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com',
  attributes: { 'objectGUID;binary': [ 'DZ�0��Dܧ�' ] } }

The above ldif output format is real life data from running ldapsearch against Microsoft AD, I only changed the dn and objectGUID value to protect the innocent. The ;binary option is not added automatically by AD, more on that below.

Guessing which attributes are truly binary and which can be decoded to string is a hard problem (read - probably no better solution that enumerate binary exceptions, spec doesn't say anything about it). Another product (node-LDAP) solves this by letting application code to "tag" attributes with ";binary" option when searching. AD server doesn't care and returns the same data in both cases, but parser library can use such tag and return the attributes as Buffer. Either Buffer or original base64 string would be fine, but binary data decoded into javascript string is definitely not fine.

Unfortunately I'm not in the position to learn peg and send a PR.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions