Esempio n. 1
0
        /// <summary>
        /// Lower case a string according to the internal NTDLL string routines.
        /// </summary>
        /// <param name="str">The string to lower case.</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The lower case string.</returns>
        public static NtResult <string> Downcase(string str, bool throw_on_error)
        {
            UnicodeStringOut out_str = new UnicodeStringOut();

            try {
                return(NtRtl.RtlUpcaseUnicodeString(ref out_str, new UnicodeString(str), true).CreateResult(throw_on_error, () => out_str.ToString()));
            } finally {
                NtRtl.RtlFreeUnicodeString(ref out_str);
            }
        }
Esempio n. 2
0
 private static IEnumerable <AccountRight> ParseRights(SafeLsaHandle policy, string system_name, SafeLsaMemoryBuffer buffer, int count)
 {
     using (buffer) {
         buffer.Initialize <UnicodeStringOut>((uint)count);
         UnicodeStringOut[] ss = new UnicodeStringOut[count];
         buffer.ReadArray(0, ss, 0, count);
         return(ss.Select(s => new AccountRight(system_name, s.ToString(),
                                                GetSids(policy, s.ToString(), false).GetResultOrDefault())).ToList());
     }
 }
Esempio n. 3
0
        private static KerberosPrincipalName ParseName(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                return(new KerberosPrincipalName());
            }
            KerberosNameType name_type = (KerberosNameType)Marshal.ReadInt16(ptr, 0);
            int count = Marshal.ReadInt16(ptr, 2);

            if (count == 0)
            {
                return(new KerberosPrincipalName(name_type, new string[0]));
            }

            var name = new SafeStructureInOutBuffer <KERB_EXTERNAL_NAME>(ptr, Marshal.SizeOf(typeof(KERB_EXTERNAL_NAME))
                                                                         + Marshal.SizeOf(typeof(UnicodeStringOut)) * count, false);

            UnicodeStringOut[] names = new UnicodeStringOut[count];
            name.Data.ReadArray(0, names, 0, count);
            return(new KerberosPrincipalName(name_type, names.Select(u => u.ToString())));
        }