H
Hari Shankar
Hello folks
I have to get the NTFS permissions of a folder programmatically. I am using
C#. Pls hint me if i am missing anything in the code below.
private void GetSecurityPermission(string strShareName)
{
NERR eRetVal = NERR.ERROR_FAILURE;
EXPLICIT_ACCESS oEA;
IntPtr pZero = IntPtr.Zero; IntPtr pSidOwner = pZero; IntPtr pSidGroup =
pZero; IntPtr pSACL = pZero; IntPtr pDACL = pZero;IntPtr psd = pZero;
int nExplicitEntriesCount = 0;bool bDaclPresent;IntPtr ppDacl;bool
bDaclDefaulted;
///Get the DACL information of strShareName using GetNamedSecurityInfo()
API.
/// SE_FILE_OBJECT constant says that the named securable object is a
file or folder
eRetVal = CDecls.GetNamedSecurityInfo(strShareName,
SE_OBJECT_TYPE.SE_FILE_OBJECT,
SECURITY_INFORMATION.DACL_SECURITY_INFORMATION, out pSidOwner,
out pSidGroup, out pDACL, out pSACL, out psd);
if (eRetVal == NERR.ERROR_SUCCESS)
{
eRetVal = CDecls.GetExplicitEntriesFromAcl(pDACL, ref
nExplicitEntriesCount, out oEA);
if(eRetVal == NERR.ERROR_SUCCESS)
{
for (int nIndex = 0; nIndex < nExplicitEntriesCount; nIndex++)
{
}
}
}
}
Thanx a ton.
Ciao
Hari
I have to get the NTFS permissions of a folder programmatically. I am using
C#. Pls hint me if i am missing anything in the code below.
private void GetSecurityPermission(string strShareName)
{
NERR eRetVal = NERR.ERROR_FAILURE;
EXPLICIT_ACCESS oEA;
IntPtr pZero = IntPtr.Zero; IntPtr pSidOwner = pZero; IntPtr pSidGroup =
pZero; IntPtr pSACL = pZero; IntPtr pDACL = pZero;IntPtr psd = pZero;
int nExplicitEntriesCount = 0;bool bDaclPresent;IntPtr ppDacl;bool
bDaclDefaulted;
///Get the DACL information of strShareName using GetNamedSecurityInfo()
API.
/// SE_FILE_OBJECT constant says that the named securable object is a
file or folder
eRetVal = CDecls.GetNamedSecurityInfo(strShareName,
SE_OBJECT_TYPE.SE_FILE_OBJECT,
SECURITY_INFORMATION.DACL_SECURITY_INFORMATION, out pSidOwner,
out pSidGroup, out pDACL, out pSACL, out psd);
if (eRetVal == NERR.ERROR_SUCCESS)
{
eRetVal = CDecls.GetExplicitEntriesFromAcl(pDACL, ref
nExplicitEntriesCount, out oEA);
if(eRetVal == NERR.ERROR_SUCCESS)
{
for (int nIndex = 0; nIndex < nExplicitEntriesCount; nIndex++)
{
}
}
}
}
Thanx a ton.
Ciao
Hari