node-activedirectory icon indicating copy to clipboard operation
node-activedirectory copied to clipboard

Formating ObjectSid

Open thdq opened this issue 5 years ago • 0 comments

Hi, i'm trying read the ObjectSid in string format (Ex: S-1-X-XX-XXXXX...), I can get objectSid in two formats, Array buffer or wrong string, same bellow:

Buffer:

"objectSid": {
    "type": "Buffer",
    "data": [
      1,
      5,
      0,
      0,
      0,
      0,
      0,
      5,
      21,
      0,
      0,
      0,
      119,
      239,
      79,
      55,
      6,
      72,
      69,
      193,
      225,
      119,
      32,
      23,
      173,
      187,
      0,
      0
    ]
  }, 

String (?):

 "objectSid": "\u0001\u0005\u0000\u0000\u0000\u0000\u0000\u0005\u0015\u0000\u0000\u0000w�O7\u0006HE��w \u0017xC\u0000\u0000", 

My method entryParser from Active Directory instance is like this:

entryParser(entry, raw, callback) {
      
        if (raw.hasOwnProperty("objectSid")) { 

          // for wrong string: entry.objectSid = entry.objectSid
          entry.objectSid = raw.objectSid;
        }

        callback(entry);
      },

How I can format the ArrayBuffer from readble string as "S-1-X-XX..." format?

thdq avatar Jun 01 '20 11:06 thdq