コード例 #1
0
ファイル: ACL.cs プロジェクト: vossjannik/ldap4net
        /// <summary>
        ///     Load the ACL from the buffer returning the last ACL segment position into the buffer.
        ///     @param buff source buffer.
        ///     @param start start loading position.
        ///     @return last loading position.
        /// </summary>
        public void Parse(BinaryReader buff, long start)
        {
            buff.BaseStream.Seek(start, SeekOrigin.Begin);

            // read for Dacl
            byte[] bytes = NumberFacility.GetBytes(buff.ReadInt32());
            this.revision = AclRevisionExtension.ParseValue(bytes[0]);

            bytes = NumberFacility.GetBytes(buff.ReadInt32());
            int aceCount = NumberFacility.GetInt(bytes[1], bytes[0]);

            for (var i = 0; i < aceCount; i++)
            {
                Ace ace = new Ace();
                this.aces.Add(ace);

                ace.Parse(buff);
            }
        }
コード例 #2
0
        /// <summary>
        ///     Load the ACE from the buffer returning the last ACE segment position into the buffer.
        ///     @param buff source buffer.
        ///     @param start start loading position.
        ///     @return last loading position.
        /// </summary>
        public void Parse(BinaryReader buff)
        {
            var start = buff.BaseStream.Position;

            byte[] bytes = NumberFacility.GetBytes(buff.ReadInt32());
            this.type  = AceTypeExtension.ParseValue(bytes[0]);
            this.flags = AceFlagExtension.ParseValue(bytes[1]);

            int size = NumberFacility.GetInt(bytes[3], bytes[2]);

            this.rights = AceRights.ParseValue(NumberFacility.GetReverseInt(buff.ReadInt32()));

            if (this.type == AceType.AccessAllowedObjectAceType || this.type == AceType.AccessDeniedObjectAceType)
            {
                this.objectFlags = AceObjectFlags.ParseValue(NumberFacility.GetReverseInt(buff.ReadInt32()));

                if (this.objectFlags.GetFlags().Contains(AceObjectFlags.Flag.AceObjectTypePresent))
                {
                    this.objectType = new Guid(buff.ReadBytes(16));
                }

                if (this.objectFlags.GetFlags().Contains(AceObjectFlags.Flag.AceInheritedObjectTypePresent))
                {
                    this.inheritedObjectType = new Guid(buff.ReadBytes(16));
                }
            }

            this.sid = new SID();
            this.sid.Parse(buff);

            if (size > 0)
            {
                var lastPos = start + size;
                this.applicationData = new byte[lastPos - buff.BaseStream.Position];

                for (var i = 0; i < applicationData.Length; i++)
                {
                    this.applicationData[i] = buff.ReadByte();
                }
            }
        }