예제 #1
0
 public SecurityAttributes(CommonObjectSecurity objectSecurity)
 {
     _length = Marshal.SizeOf(typeof(SecurityAttributes));
     byte[] src = objectSecurity.GetSecurityDescriptorBinaryForm();
     _securityDescriptor = Marshal.AllocHGlobal(src.Length);
     Marshal.Copy(src, 0, _securityDescriptor, src.Length);
     _inheritHandle = false;
 }
예제 #2
0
            public SystemMandatoryLabel(CommonObjectSecurity sec)
            {
                Policy = SystemMandatoryLabelPolicy.None;
                Level  = SystemMandatoryLabelLevel.None;

                try
                {
                    var sd = new RawSecurityDescriptor(sec.GetSecurityDescriptorBinaryForm(), 0);
                    if (sd.SystemAcl != null)
                    {
                        foreach (var ace in sd.SystemAcl)
                        {
                            if ((int)ace.AceType == 0x11)
                            {
                                byte[] aceBytes = new byte[ace.BinaryLength];
                                ace.GetBinaryForm(aceBytes, 0);
                                //_policy = new IntegrityPolicy(aceBytes, 4);
                                //_level = new IntegrityLevel(aceBytes, 8);
                            }
                        }
                    }
                }
                catch { }

                /*byte[] saclBinaryForm = new byte[sd.SystemAcl.BinaryLength];
                 * sd.SystemAcl.GetBinaryForm(saclBinaryForm, 0);
                 * GenericAce ace = null;
                 * if (null != saclBinaryForm)
                 * {
                 *      RawAcl aclRaw = new RawAcl(saclBinaryForm, 0);
                 *      if (0 >= aclRaw.Count) throw new ArgumentException("No ACEs in ACL", "saclBinaryForm");
                 *      ace = aclRaw[0];
                 *      if (Win32.SYSTEM_MANDATORY_LABEL_ACE_TYPE != (int)ace.AceType)
                 *              throw new ArgumentException("No Mandatory Integrity Label in ACL", "saclBinaryForm");
                 *      byte[] aceBytes = new byte[ace.BinaryLength];
                 *      ace.GetBinaryForm(aceBytes, 0);
                 *      _policy = new IntegrityPolicy(aceBytes, 4);
                 *      _level = new IntegrityLevel(aceBytes, 8);
                 *      return;
                 * }
                 * throw new ArgumentNullException("saclBinaryForm");*/
            }