Beispiel #1
0
            private static byte[] GetBytes(System.Security.Principal.SecurityIdentifier si)
            {
                var b = new byte[si.BinaryLength];

                si.GetBinaryForm(b, 0);
                return(b);
            }
Beispiel #2
0
        public static string EncodeSidToString(string sid)
        {
            var realsid = new System.Security.Principal.SecurityIdentifier(sid);
            var bytesid = new byte[realsid.BinaryLength];

            realsid.GetBinaryForm(bytesid, 0);
            return("\\" + BitConverter.ToString(bytesid).Replace("-", "\\"));
        }
Beispiel #3
0
 public static string EncodeSidToString(string sid)
 {
     try
     {
         var realsid = new System.Security.Principal.SecurityIdentifier(sid);
         var bytesid = new byte[realsid.BinaryLength];
         realsid.GetBinaryForm(bytesid, 0);
         return("\\" + BitConverter.ToString(bytesid).Replace("-", "\\"));
     }
     catch (ArgumentException)
     {
         Trace.WriteLine("Unable to encode " + sid);
         throw;
     }
 }
Beispiel #4
0
        protected override BitStream internalEncode(BitStream data)
        {
            var sids = System.Text.ASCIIEncoding.ASCII.GetString(data.Value);

            try
            {
                //Hopefully this is in mono...
                var    sid  = new System.Security.Principal.SecurityIdentifier(sids);
                byte[] bsid = new byte[sid.BinaryLength];
                sid.GetBinaryForm(bsid, 0);

                return(new BitStream(bsid));
            }
            catch (Exception ex)
            {
                throw new PeachException("Error, Cannot convert string to sid" + sids, ex);
            }
        }
        protected override BitwiseStream internalEncode(BitwiseStream data)
        {
            var sids = new BitReader(data).ReadString();

            try
            {
                //Hopefully this is in mono...
                var    sid  = new System.Security.Principal.SecurityIdentifier(sids);
                byte[] bsid = new byte[sid.BinaryLength];
                sid.GetBinaryForm(bsid, 0);

                var ret = new BitStream();
                ret.Write(bsid, 0, bsid.Length);
                ret.Seek(0, System.IO.SeekOrigin.Begin);
                return(ret);
            }
            catch (Exception ex)
            {
                throw new SoftException("Error, cannot convert string '" + sids + "' to SID.", ex);
            }
        }