예제 #1
0
        public static IEnumerable <INHERITED_FROM> GetInheritanceSource(string objectName, ResourceType objectType,
                                                                        SECURITY_INFORMATION securityInfo, bool container, IntPtr pAcl, ref GENERIC_MAPPING pGenericMapping)
        {
            var objSize  = Marshal.SizeOf(typeof(INHERITED_FROM));
            var aceCount = GetAceCount(pAcl);

            using (var pInherit = new SafeCoTaskMemHandle(objSize * (int)aceCount))
            {
                var hr = 0;
                try
                {
                    hr = AdvApi32.GetInheritanceSource(objectName, objectType, securityInfo, container, null, 0, pAcl, IntPtr.Zero, ref pGenericMapping, (IntPtr)pInherit);
                    if (hr != 0)
                    {
                        throw new System.ComponentModel.Win32Exception(hr);
                    }
                    return(pInherit.ToIEnum <INHERITED_FROM>((int)aceCount));
                }
                finally
                {
                    if (hr != 0)
                    {
                        FreeInheritedFromArray((IntPtr)pInherit, (ushort)aceCount, IntPtr.Zero);
                    }
                }
            }
        }
예제 #2
0
        public static IEnumerable <INHERITED_FROM> GetInheritanceSource(string objectName, System.Security.AccessControl.ResourceType objectType,
                                                                        SECURITY_INFORMATION securityInfo, bool container, IntPtr pAcl, ref GENERIC_MAPPING pGenericMapping)
        {
            var objSize  = Marshal.SizeOf(typeof(INHERITED_FROM));
            var aceCount = GetAceCount(pAcl);

            using (var pInherit = new SafeInheritedFromArray((ushort)aceCount))
            {
                AdvApi32.GetInheritanceSource(objectName, (SE_OBJECT_TYPE)objectType, securityInfo, container, null, 0, pAcl, IntPtr.Zero, ref pGenericMapping, pInherit).ThrowIfFailed();
                return(pInherit.Results);
            }
        }