コード例 #1
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());
     }
 }
コード例 #2
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())));
        }