Hi,

I'm trying to check whether a user has access to certain
files/directories and which class of access he has. As I've read in
other posts, it is not adviced to use the "high-level access control
API". So I've tried to get my information using the following code
(simplified):

ACE_HEADER hdr;
SECURITY_DESCRIPTOR secDesc[15];
DWORD size;
size = BUF_SIZE;
DWORD secDescSize = sizeof(secDesc);
ZeroMemory((void *)secDesc, secDescSize);
result = GetFileSecurity("d:\\rehm\\fluss\\f2d_1031.dll",
DACL_SECURITY_INFORMATION, secDesc, secDescSize, &size);
result = GetSecurityDescriptorDacl(secDesc, &present, &pDACL,
&defaulted);
GetAce(pDACL, 0, (void **)&hdr);
PACCESS_ALLOWED_ACE pAllowedAce;
pAllowedAce = (PACCESS_ALLOWED_ACE)&hdr;

GetAce() yields strange values for hdr.AceType (something like 0xD4)
instead of ACCESS_ALLOWED_ACE_TYPE which should be returned. Anybody
has made similar experiences? I also found the function AccessCheck().
Anybody used it? Some sample code would be great.
Thanks in advance!

Hannes

Re: Check access to file/directory by Dave

Dave
Mon Sep 26 09:20:27 CDT 2005

Try asking them here.

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.languages.vc&cat=en_US_e0896eea-b99a-41a4-8d11-9ee01d5c3b3d&lang=en&cr=US

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"hoenes1" wrote:
| Hi,
|
| I'm trying to check whether a user has access to certain
| files/directories and which class of access he has. As I've read in
| other posts, it is not adviced to use the "high-level access control
| API". So I've tried to get my information using the following code
| (simplified):
|
| ACE_HEADER hdr;
| SECURITY_DESCRIPTOR secDesc[15];
| DWORD size;
| size = BUF_SIZE;
| DWORD secDescSize = sizeof(secDesc);
| ZeroMemory((void *)secDesc, secDescSize);
| result = GetFileSecurity("d:\\rehm\\fluss\\f2d_1031.dll",
| DACL_SECURITY_INFORMATION, secDesc, secDescSize, &size);
| result = GetSecurityDescriptorDacl(secDesc, &present, &pDACL,
| &defaulted);
| GetAce(pDACL, 0, (void **)&hdr);
| PACCESS_ALLOWED_ACE pAllowedAce;
| pAllowedAce = (PACCESS_ALLOWED_ACE)&hdr;
|
| GetAce() yields strange values for hdr.AceType (something like 0xD4)
| instead of ACCESS_ALLOWED_ACE_TYPE which should be returned. Anybody
| has made similar experiences? I also found the function AccessCheck().
| Anybody used it? Some sample code would be great.
| Thanks in advance!
|
| Hannes
|