Click here to Skip to main content
15,921,694 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Which one is faster? Pin
Anders Molin13-Jun-01 1:58
professionalAnders Molin13-Jun-01 1:58 
GeneralOutlook Address Book Pin
13-Jun-01 1:09
suss13-Jun-01 1:09 
GeneralRe: Outlook Address Book Pin
Michael P Butler13-Jun-01 22:23
Michael P Butler13-Jun-01 22:23 
GeneralRe: Outlook Address Book Pin
14-Jun-01 0:47
suss14-Jun-01 0:47 
GeneralInserting HTML with CHtmlView ... Pin
13-Jun-01 0:58
suss13-Jun-01 0:58 
QuestionHow to get a point to client window Pin
Kiddxin12-Jun-01 23:09
Kiddxin12-Jun-01 23:09 
GeneralReading Excel DB using CRecordset Pin
12-Jun-01 22:03
suss12-Jun-01 22:03 
GeneralFinding a user's group membership. Pin
Taka Muraoka12-Jun-01 21:43
Taka Muraoka12-Jun-01 21:43 
Does anyone know how I can find out what NT groups a user belongs to.

Given a domain and account name, I can get the user's SID but I would like to find out (recursively) what groups he belongs to. I need this so that I can walk a DACL to see if he has access to a given file. I would like to use GetEffectiveRightsFromAcl() but it appears to be totally broken (MSDN sez that it fails under NT4 SP4 and SP6; my testing shows that it has problems under W2K as well). My code works fine for user SID's but obviously I need to take into account group memberships as well.

As an aside, I also tried getting a token (via LogonUser()) and calling AccessCheck() which works fine for files that have no security assigned. When I try to assign an ACE (via Explorer), AccessCheck() fails with ERROR_INVALID_SECURITY_DESCR ("The security descriptor structure is invalid").

// log the user on
HANDLE hToken ;
DWORD rc = LogonUser( pUserName , pDomain , pPassword , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , &hToken ) ;
assert( rc ) ;

// get the file's DACL
HANDLE hFile = CreateFile( "d:/tmp/junk" , GENERIC_READ , 0 , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL ) ;
assert( hFile != INVALID_HANDLE_VALUE ) ;
SECURITY_DESCRIPTOR* pSD ;
ACL* pACL ;
rc = GetSecurityInfo( hFile , SE_FILE_OBJECT , DACL_SECURITY_INFORMATION , NULL , NULL , &pACL , NULL , (void**)&pSD ) ;
CloseHandle( hFile ) ;
assert( rc == ERROR_SUCCESS ) ;

// check if we have access
DWORD desiredAccess = FILE_READ_ATTRIBUTES ;
GENERIC_MAPPING genericMapping ;
PRIVILEGE_SET privilegeSet ;
DWORD privilegeSetLen = sizeof(privilegeSet) ;
DWORD grantedAccess ;
BOOL accessStatus ;
rc = AccessCheck( pSD , hToken , desiredAccess , &genericMapping ,
                  &privilegeSet , &privilegeSetLen , &grantedAccess , &accessStatus
                ) ;
assert( rc ) ; // *** FAILS HERE ***/
cout << "AccessStatus=" << accessStatus << endl ;

GeneralRe: Finding a user's group membership. Pin
Tomasz Sowinski13-Jun-01 2:12
Tomasz Sowinski13-Jun-01 2:12 
GeneralRe: Finding a user's group membership. Pin
Taka Muraoka13-Jun-01 4:18
Taka Muraoka13-Jun-01 4:18 
GeneralRe: Finding a user's group membership. Pin
Tomasz Sowinski13-Jun-01 4:32
Tomasz Sowinski13-Jun-01 4:32 
GeneralDisconnected Recordset Pin
yamini12-Jun-01 21:21
yamini12-Jun-01 21:21 
GeneralWhen focus is set to a checkbox Pin
12-Jun-01 20:25
suss12-Jun-01 20:25 
GeneralRe: When focus is set to a checkbox Pin
Tomasz Sowinski13-Jun-01 1:05
Tomasz Sowinski13-Jun-01 1:05 
GeneralDrawing Pin
Drake Elsari12-Jun-01 17:56
Drake Elsari12-Jun-01 17:56 
GeneralRe: Drawing Pin
Tomasz Sowinski13-Jun-01 1:10
Tomasz Sowinski13-Jun-01 1:10 
GeneralDictionary programs Pin
12-Jun-01 17:20
suss12-Jun-01 17:20 
GeneralRe: Dictionary programs Pin
l a u r e n12-Jun-01 21:24
l a u r e n12-Jun-01 21:24 
GeneralTree control in a dialog Pin
12-Jun-01 17:17
suss12-Jun-01 17:17 
GeneralRe: Tree control in a dialog Pin
Tomasz Sowinski13-Jun-01 1:18
Tomasz Sowinski13-Jun-01 1:18 
GeneralRe: Tree control in a dialog Pin
Vu Nguyen9-Oct-01 14:57
Vu Nguyen9-Oct-01 14:57 
Generaltext file io in Embedded VC++ Pin
bo12-Jun-01 16:07
bo12-Jun-01 16:07 
QuestionMessage for window overlapping? Pin
BryanBHU12-Jun-01 15:46
BryanBHU12-Jun-01 15:46 
AnswerRe: Message for window overlapping? Pin
Tomasz Sowinski13-Jun-01 2:20
Tomasz Sowinski13-Jun-01 2:20 
GeneralRe: Message for window overlapping? Pin
BryanBHU13-Jun-01 15:42
BryanBHU13-Jun-01 15:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.