Getting Folder Permissions

From: Hari Shankar (Hari.Shankar_at_in.bosch.com)
Date: 03/22/04


Date: Mon, 22 Mar 2004 18:33:05 +0530

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



Relevant Pages

  • Getting Folder Permissions
    ... I have to get the NTFS permissions of a folder programmatically. ... Pls hint me if i am missing anything in the code below. ... Thanx a ton. ...
    (microsoft.public.platformsdk.security)
  • Re: Is anyone out there?
    ... >> perhaps i am missing something ... > Ill give you one hint... ... Ahh, so what's your favourite Hospital Meal? ...
    (uk.rec.scouting)
  • Re: Non deterministic behaviour in quartus II ?
    ... Will Dean wrote: ... there is the possibility that I am missing some point. ... Do you have any idea *why* your cicuit doesn't work when it doesn't? ...
    (comp.arch.fpga)
  • Re: exec() launched from Linux for Win commands
    ... > What is missing or wrong in my job? ... > Any suggestion or hint will be very useful, ... brian ... ...
    (comp.lang.php)
  • NTFS Permissions for WinXP Pro
    ... Can someone tell me how to set the NTFS permissions under WinXP Pro. ... I used to simply right-click the directory in File Explorer and go to the ... It's missing on XP.... ...
    (microsoft.public.windowsxp.general)