Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to use GetFileSecurity function in C

Posted on 2000-02-18
1
728 Views
Last Modified: 2008-02-20
Im using the GetFileSecurity function in C and im getting the following error 'The data area passed to a system call is too small'. the requestedinformation variable is set to 1 for an owner information request.  

my variable are :
SECURITY_INFORMATION requestedinformation;
SECURITY_DESCRIPTOR psecuritydescriptor;
DWORD lpnlengthneeded;
char temp_name[20] = "test.txt";

the function call is :
GetFileSecurity((LPCTSTR)temp_name,requestedinformation,&psecuritydescriptor,sizeof(SECURITY_DESCRIPTOR),&lpnlengthneeded);
0
Comment
Question by:makerp
1 Comment
 
LVL 1

Accepted Solution

by:
ScottyDawg earned 50 total points
ID: 2535347
SECURITY_DESCRIPTOR is a variable length block that you must allocate before entry to the function (its actually defined as a pointer to void).

i.e. char sd[100];

and pass this into function call.

the lpnlengthneeded will be zero if there was sufficient space to copy the security attributes. If its not zero, then the sd buffer wasn't large enough.

Take a look at the following routines for manipulating the SD after you've called this function:

GetSecurityDescriptorControl, GetSecurityDescriptorDacl, GetSecurityDescriptorGroup, GetSecurityDescriptorLength, GetSecurityDescriptorOwner, GetSecurityDescriptorSacl, InitializeSecurityDescriptor, IsValidSecurityDescriptor, SetSecurityDescriptorDacl, SetSecurityDescriptorGroup, SetSecurityDescriptorOwner, SetSecurityDescriptorSacl
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question