[DllImport("advapi32.dll", CharSet=CharSet.Auto)]
static extern uint SetNamedSecurityInfo(
string pObjectName,
SE_OBJECT_TYPE ObjectType,
SECURITY_INFORMATION SecurityInfo,
IntPtr psidOwner,
IntPtr psidGroup,
IntPtr pDacl,
IntPtr pSacl);
Declare Function SetNamedSecurityInfo Lib "advapi32.dll" ( _
ByVal pObjectName As String, _
ByVal ObjectType As SE_OBJECT_TYPE, _
ByVal SecurityInfo As SECURITY_INFORMATION, _
ByVal psidOwner As IntPtr, _
ByVal psidGroup As IntPtr, _
ByVal pDacl As IntPtr, _
ByVal pSacl As IntPtr) As Integer
None.
Please add some!
Please add some!
Dim pSecDesc, pNewDACL, pOldDACL As IntPtr
Dim ea As EXPLICIT_ACCESS
Dim Win32Error As Win32Exception
Dim ret As Integer
' merge this Explict Access with the existing DACL
ret = SetEntriesInAcl(1, ea, pOldDACL, pNewDACL)
If ret <> 0 Then
Win32Error = New Win32Exception(ret)
Throw New Exception(Win32Error.Message)
End If
' write the new Security Descriptor/DACL back
ret = SetNamedSecurityInfo(strPath, _
SE_OBJECT_TYPE.SE_FILE_OBJECT, _
SECURITY_INFORMATION.DACL_SECURITY_INFORMATION, _
Nothing, Nothing, pNewDACL, Nothing)
If ret <> 0 Then
Win32Error = New Win32Exception(ret)
Throw New Exception(Win32Error.Message)
End If
Do you know one? Please contribute it!