Last active
August 29, 2015 14:19
Get service SID from service name
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 characters
open System.Security.Cryptography | |
open System.Security.Principal | |
open System.Text | |
open System | |
// 1st arg (index [0]) is this script | |
let name = fsi.CommandLineArgs.[1] | |
let hash = new SHA1CryptoServiceProvider() | |
let tail = name.ToUpper() | |
|> Encoding.Unicode.GetBytes | |
|> (fun x -> hash.ComputeHash(x)) | |
let head = [|1uy; 6uy; 0uy; 0uy; 0uy; 0uy; 0uy; 5uy; 80uy; 0uy; 0uy; 0uy |] | |
let binary = Array.append head tail | |
let sid = new SecurityIdentifier(binary, 0) | |
Console.WriteLine(sid.ToString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment