objectGUID: Buffer encoding issue
See original GitHub issueHey there, seems like the returned objectGUID
during a search on the active directory has an encoding issue.
Once returned and converted to a readable UUID, it doesn’t matched the real value provided by the AD. Is it a know issue or something wrong on my side?
Search response:
// Excepted
{ objectGUID: 'â\u0018!;óì@¯Wa8`ß' }
// 3b2118e2-f39c-40ec-af57-6190389660df
// Returned
{ objectGUID: '�\u0018!;���@�Wa�8�`�' }
// 3b2118fd-fdfd-40fd-fd57-61fd38fd60fd
Temporary workaround:
export const formatEntry = entryObject => {
const { object, attributes } = entryObject;
const objectGUIDAttribute = attributes.find(
attr => attr.type === 'objectGUID'
);
return {
...object,
objectGUID: Buffer.from(
objectGUIDAttribute.buffers[0],
'hex'
).toString('binary')
};
};
Convert objectGUID to readable UUID:
export const objectGUIDToUUID = objectGUID => {
const hex = Buffer.from(objectGUID, 'binary').toString('hex');
const p1 =
hex.substr(-26, 2) +
hex.substr(-28, 2) +
hex.substr(-30, 2) +
hex.substr(-32, 2);
const p2 = hex.substr(-22, 2) + hex.substr(-24, 2);
const p3 = hex.substr(-18, 2) + hex.substr(-20, 2);
const p4 = hex.substr(-16, 4);
const p5 = hex.substr(-12, 12);
return [p1, p2, p3, p4, p5].join('-');
};
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:13 (1 by maintainers)
Top Results From Across the Web
objectGUID: Buffer encoding issue #481 - ldapjs/node-ldapjs
Hey there, seems like the returned objectGUID during a search on the active directory has an encoding issue.
Read more >encoding - Issue with ldapjs and string base64 format
I have a LDAP server and the users have a property which is a jpeg photo in base64 format. When I search for...
Read more >Chapter 4, Searching and Manipulating Objects - O'Reilly
Connecting to an Object GUID. Problem. You want to bind to a container using its Globally Unique Identifier (GUID) ...
Read more >Buffer | Node.js v19.3.0 Documentation
When encoding a Buffer to a string, this encoding will omit padding. 'hex' : Encode each byte as two hexadecimal characters. Data truncation...
Read more >How was this value of ObjectGUID encoded? - Super User
I basically have to decode the applications encoding of objectGUID .. to identify the corresponding MSAD entries.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this is my small transfer-function (you can remove the comment… only for understanding)
You can get the bin data from
attributes
on the response.Like this: