/// <summary>
        /// Construct a SID from a binary reader.
        /// </summary>
        /// <param name="reader">The binary reader.</param>
        internal Sid(BinaryReader reader)
        {
            int revision = reader.ReadByte();

            if (revision != 1)
            {
                throw new NtException(NtStatus.STATUS_INVALID_SID);
            }
            int subauth_count = reader.ReadByte();

            byte[]      authority = reader.ReadAllBytes(6);
            List <uint> subauth   = new List <uint>();

            for (int i = 0; i < subauth_count; ++i)
            {
                subauth.Add(reader.ReadUInt32());
            }

            SubAuthorities = subauth;
            Authority      = new SidIdentifierAuthority(authority);
        }
Beispiel #2
0
        /// <summary>
        /// Compares authority to another.
        /// </summary>
        /// <param name="obj">The other authority to compare against.</param>
        /// <returns>True if authority is equal.</returns>
        public override bool Equals(object obj)
        {
            SidIdentifierAuthority auth = obj as SidIdentifierAuthority;

            if (auth == null)
            {
                return(false);
            }

            if (base.Equals(obj))
            {
                return(true);
            }

            for (int i = 0; i < _value.Length; i++)
            {
                if (_value[i] != auth._value[i])
                {
                    return(false);
                }
            }

            return(true);
        }
 /// <summary>
 /// Constructor for authority and sub authorities.
 /// </summary>
 /// <param name="authority">The identifier authority.</param>
 /// <param name="sub_authorities">The sub authorities.</param>
 public Sid(SidIdentifierAuthority authority, params uint[] sub_authorities)
 {
     Authority      = new SidIdentifierAuthority(authority.Value);
     SubAuthorities = new List <uint>(sub_authorities);
 }
 public static extern NtStatus RtlAllocateAndInitializeSidEx(SidIdentifierAuthority IdentifierAuthority,
                                                             byte SubAuthorityCount, [Out] uint[] SubAuthorities, out SafeSidBufferHandle Sid);
 public static extern NtStatus RtlAllocateAndInitializeSid(SidIdentifierAuthority IdentifierAuthority,
                                                           byte SubAuthorityCount, uint SubAuthority0, uint SubAuthority1, uint SubAuthority2, uint SubAuthority3,
                                                           uint SubAuthority4, uint SubAuthority5, uint SubAuthority6, uint SubAuthority7, out SafeSidBufferHandle Sid);
 public static extern NtStatus RtlInitializeSid(IntPtr Sid, SidIdentifierAuthority IdentifierAuthority, byte SubAuthorityCount);
 /// <summary>
 /// Constructor for authority and sub authorities.
 /// </summary>
 /// <param name="authority">The identifier authority.</param>
 /// <param name="sub_authorities">The sub authorities.</param>
 public Sid(SidIdentifierAuthority authority, params uint[] sub_authorities)
 {
     Authority = new SidIdentifierAuthority(authority.Value);
     SubAuthorities = new List<uint>(sub_authorities);
 }