-
-
Save simonneutert/0e9a037b7036b5fc137f598f72e52e30 to your computer and use it in GitHub Desktop.
Revisions
-
Krizzzn revised this gist
Jun 19, 2017 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,16 @@ /* # Convert binary encoded object SID to a string # (eg. S-1-5-21-1004336348-1177238915-682003330-512) # # SID format: https://technet.microsoft.com/en-us/library/cc962011.aspx # # ldapjs `searchEntry` has attribute `raw` that holds the raw # values, including the `objectSid` buffer when one exists. Pass that # buffer to get the string representation that can then be easily # used in LDAP search filters, for example. # */ let pad = function(s) { if (s.length < 2) { return `0${s}`; } else { return s; } }; let sidBufferToString = function(buf) { -
Krizzzn revised this gist
Jun 19, 2017 . 2 changed files with 31 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,32 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ let pad = function(s) { if (s.length < 2) { return `0${s}`; } else { return s; } }; let sidBufferToString = function(buf) { let asc, end; let i; if (buf == null) { return null; } let version = buf[0]; let subAuthorityCount = buf[1]; let identifierAuthority = parseInt(((() => { let result = []; for (i = 2; i <= 7; i++) { result.push(buf[i].toString(16)); } return result; })()).join(''), 16); let sidString = `S-${version}-${identifierAuthority}`; for (i = 0, end = subAuthorityCount-1, asc = 0 <= end; asc ? i <= end : i >= end; asc ? i++ : i--) { let subAuthOffset = i * 4; let tmp = pad(buf[11 + subAuthOffset].toString(16)) + pad(buf[10 + subAuthOffset].toString(16)) + pad(buf[9 + subAuthOffset].toString(16)) + pad(buf[8 + subAuthOffset].toString(16)); sidString += `-${parseInt(tmp, 16)}`; } return sidString; }; -
vesse revised this gist
May 19, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,9 @@ # buffer to get the string representation that can then be easily # used in LDAP search filters, for example. # pad = (s) -> if s.length < 2 then "0#{s}" else s sidBufferToString = (buf) -> return null unless buf? -
vesse created this gist
May 19, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ # Convert binary encoded object SID to a string # (eg. S-1-5-21-1004336348-1177238915-682003330-512) # # SID format: https://technet.microsoft.com/en-us/library/cc962011.aspx # # ldapjs `searchEntry` has attribute `raw` that holds the raw # values, including the `objectSid` buffer when one exists. Pass that # buffer to get the string representation that can then be easily # used in LDAP search filters, for example. # sidBufferToString = (buf) -> return null unless buf? version = buf[0] subAuthorityCount = buf[1] identifierAuthority = parseInt((buf[i].toString(16) for i in [2..7]).join(''), 16) sidString = "S-#{version}-#{identifierAuthority}" for i in [0..subAuthorityCount-1] subAuthOffset = i * 4 tmp = pad(buf[11 + subAuthOffset].toString(16)) + pad(buf[10 + subAuthOffset].toString(16)) + pad(buf[9 + subAuthOffset].toString(16)) + pad(buf[8 + subAuthOffset].toString(16)) sidString += '-' + parseInt(tmp, 16) sidString