Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to use GetFileSecurity function in C

Posted on 2000-02-18
1
Medium Priority
?
765 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 200 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

Industry Leaders: 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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

722 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