Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I've a strange behaviour :

First, I call QueryServiceObjectSecurity() to retrieve a security descriptor on a service handle.
The call works well, no error, and I get data.
I can call GetSecurityDescriptorDacl() on the structure returned, it works. So, I assume that the security descriptor returned is a good one.

Here is an extract of code :

C#
// Some variables used

SC_HANDLE hService;
PSECURITY_DESCRIPTOR SecDesc=NULL;
DWORD allocatedSize=0;
DWORD SecDescSizeNeeded=0;

// hService is initialized by a call to OpenService()

// First call to get the size needed
QueryServiceObjectSecurity(hService,DACL_SECURITY_INFORMATION,
&SecDesc,0,&SecDescSizeNeeded)

// Calls to HeapAlloc() for memory allocation with a size of
 // SecDescSizeNeeded
allocatedSize=SecDescSizeNeeded;

 if (!QueryServiceObjectSecurity(hService,DACL_SECURITY_INFORMATION,
&SecDesc,allocatedSize,&SecDescSizeNeeded))
        {
            < some error processing >
        }

if (IsValidSecurityDescriptor(SecDesc)){
    // Descriptor is VALID ;
} else {
    // Descriptor is NOT VALID;
 
}








But... If I call IsValidSecurityDescriptor() with the PSECURITY_DESCRIPTOR structure returned by my call to QueryServiceObjectSecurity(), it always returns with FALSE ?

I can't figure out why ?

Any clue about this problem ?

Thanks in advance !

---
Gonzague
Posted
Updated 1-Feb-11 1:47am
v2
Comments
HimanshuJoshi 31-Jan-11 21:48pm    
Add some code relevant to your problem.

Try checking the value of GetLastError[^] after IsValidSecurityDescriptor() fails
 
Share this answer
 
Nice idea but the trouble is IsValidSecurityDescriptor() doesn't return any information except its boolean value.
GetLastError() has no meaning in this case :(

---
Gonzague
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900