Solved

how to use GetFileSecurity function in C

Posted on 2000-02-18
1
730 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
[X]
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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

756 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