Skip to content

Commit

Permalink
Fix GUID serialization function
Browse files Browse the repository at this point in the history
  • Loading branch information
adalinesimonian committed Jun 29, 2015
1 parent 229cf97 commit 17ed311
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/adauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,20 @@ ADAuth.prototype._binarySIDToString = function (binarySID) {

ADAuth.prototype._binaryGUIDToString = function (binaryGUID) {
var guid = '{';
var idx;
for (var i = 0; i < binaryGUID.length; i++) {
guid += (binaryGUID[i] < 0x10) ? '0' : '' +
binaryGUID[i].toString(16) +
(i === 3 || i === 5 || i === 7 || i === 9) ? '-' : '';
if (i < 4) {
idx = 3 - i;
} else if (i === 4 || i === 6) {
idx = i + 1;
} else if (i === 5 || i === 7) {
idx = i - 1;
} else {
idx = i;
}
guid += ((binaryGUID[idx] < 0x10) ? '0' : '') +
binaryGUID[idx].toString(16) +
((i === 3 || i === 5 || i === 7 || i === 9) ? '-' : '');
}
return guid + '}';
};
Expand Down

0 comments on commit 17ed311

Please sign in to comment.