I want to use the function GetFileSecurity() to retreive the security descripter of a file in the Master File Table from NTFS..
The function definition is

BOOL WINAPI GetFileSecurity(
  __in       LPCTSTR lpFileName,
  __in       SECURITY_INFORMATION RequestedInformation,
  __out_opt  PSECURITY_DESCRIPTOR pSecurityDescriptor,
  __in       DWORD nLength,
  __out      LPDWORD lpnLengthNeeded
);

The fifth attibute is the length of the Buffer in which Security descripter attribute for a particular file is stored.. But how can we know the length before extracting the Security descripter ?? Is it fixed or is there any function which can help...

Call it twice. The first time pass 0 for pSecurityDescriptor and nLength parameters -- The function will fill in the required length in the pnLengthNeeded parameter. You can then use that value to allocate buffer and call the function again.

Or you can just simply allocate a buffer large enough to hold the description -- no harm done if its larger than needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.