Solved

how to use GetFileSecurity function in C

Posted on 2000-02-18
1
699 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now