The TreeSetNamedSecurityInfo function sets specified security information in the security descriptor of a specified tree of objects.
[DllImport("advapi32.dll", EntryPoint = "TreeSetNamedSecurityInfoW", SetLastError = true, CharSet = CharSet.Unicode)]
static extern uint TreeSetNamedSecurityInfo(string pObjectName, SE_OBJECT_TYPE ObjectType, SecurityInformation SecurityInfo,
IntPtr pOwner, IntPtr pGroup, IntPtr pDacl, IntPtr pSacl, uint dwAction,
TreeSetNamedSecurityProgress fnProgress, PROGRESS_INVOKE_SETTING ProgressInvokeSetting, IntPtr Args);
// callback function
public delegate void TreeSetNamedSecurityProgress(IntPtr pObjectName, uint Status, IntPtr pInvokeSetting, IntPtr Args, Boolean SecuritySet);
None.
Do you know one? Please contribute it!
None.
Please add some!
Boolean retref, present;
// calling the function
IntPtr pSidOwner = IntPtr.Zero;
IntPtr pSidGroup = IntPtr.Zero;
IntPtr pDacl = IntPtr.Zero;
IntPtr pSacl = IntPtr.Zero;
IntPtr pTemp = IntPtr.Zero;
IntPtr pArgs = IntPtr.Zero;
GetSecurityDescriptorGroup(pSecurityDescriptor, out pSidGroup , out retref);
GetSecurityDescriptorOwner(pSecurityDescriptor, out pSidOwner, out retref));
GetSecurityDescriptorDacl(pSecurityDescriptor, out present, out pDacl, out retref);
GetSecurityDescriptorSacl(pSecurityDescriptor, out present, out pSacl, out retref);
uint errorReturn = TreeSetNamedSecurityInfo(path, SE_OBJECT_TYPE.SE_FILE_OBJECT, si, pSidOwner, pSidGroup, pDacl, pSacl, TREE_SEC_INFO_SET, callback, PROGRESS_INVOKE_SETTING.ProgressInvokePrePostError, pArgs);
The callback
void TreeSetNamedSecurityProgress(IntPtr pObjectName, uint Status, IntPtr pInvokeSetting, IntPtr Args, Boolean SecuritySet)
{
if (bCancel)
{
pInvokeSetting = new IntPtr((int)Win32FileSystem.PROGRESS_INVOKE_SETTING.ProgressCancelOperation);
return;
}
String temp = Marshal.PtrToStringAuto(pObjectName);
if(!String.IsNullOrEmpty(temp))
{
String currentItem = temp;
}
}