What I know, you need to use EditSecurity function from aclui.dll and implement ISecurityInformation interface.
[DllImport("aclui.dll", CharSet = CharSet.Auto)]
static extern bool EditSecurity(IntPtr hwnd, ISecurityInformation psi);
Interface
[Guid("965FC360-16FF-11d0-91CB-00AA00BBB723")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ISecurityInformation
{
void GetObjectInformation([Out] out SI_OBJECT_INFO pObjectInfo);
void GetSecurity([In] uint RequestedInformation, [Out] out IntPtr ppSecurityDescriptor, [In] bool fDefault);
void SetSecurity([In] uint SecurityInformation, [In] IntPtr pSecurityDescriptor);
void GetAccessRights([In] IntPtr pguidObjectType, [In] uint dwFlags, [Out] out IntPtr ppAccess, [Out] out int pcAccesses, [Out] out int piDefaultAccess);
void MapGeneric([In] IntPtr pguidObjectType, [In] IntPtr pAceFlags, [In, Out] ref uint pMask);
void GetInheritTypes([Out] out IntPtr ppInheritTypes, [Out] out int pcInheritTypes);
void PropertySheetPageCallback([In] IntPtr hwnd, [In] uint uMsg, [In] uint uPage);
}
SI_OBJECT_INFO structure
[StructLayout(LayoutKind.Sequential)]
public struct SI_OBJECT_INFO
{
public uint dwFlags;
public IntPtr hInstance;
public IntPtr pszServerName;
public IntPtr pszObjectName;
public IntPtr pszPageTitle;
public Guid guidObjectType;
}
SecurityInformation
class. Right now, I don't know how to implement all methods of ISecurityInformation
.
public class SecurityInformation : ISecurityInformation
{
SecurityInformation()
{
}
void ISecurityInformation.GetObjectInformation(out SI_OBJECT_INFO pObjectInfo)
{
pObjectInfo = new SI_OBJECT_INFO()
{
// TODO
};
}
void ISecurityInformation.GetSecurity(uint RequestedInformation, out IntPtr ppSecurityDescriptor, bool fDefault)
{
// TODO
}
void ISecurityInformation.SetSecurity(uint SecurityInformation, IntPtr pSecurityDescriptor)
{
// TODO
}
void ISecurityInformation.GetAccessRights(IntPtr pguidObjectType, uint dwFlags, out IntPtr ppAccess, out int pcAccesses, out int piDefaultAccess)
{
// TODO
}
void ISecurityInformation.MapGeneric(IntPtr pguidObjectType, IntPtr pAceFlags, ref uint pMask)
{
// TODO
}
void ISecurityInformation.GetInheritTypes(out IntPtr ppInheritTypes, out int pcInheritTypes)
{
// TODO
}
void ISecurityInformation.PropertySheetPageCallback(IntPtr hwnd, uint uMsg, uint uPage)
{
// TODO
}
}