DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   ACL TRUSTEE_TYPE is always Unknown. (http://www.daniweb.com/forums/thread166557.html)

bigbadowl Jan 6th, 2009 11:03 am
ACL TRUSTEE_TYPE is always Unknown.
 
Hi All

I am using the code below to get ACL information from files on Windows (in this case Vista). I need to know wether or not a trustee is a group or a user but when I loop through each trustee they all say "TRUSTEE_IS_UNKNOWN". Am I getting something horribly wrong?

dwError = GetExplicitEntriesFromAcl(pAcl, &cCountOfExplicitEntries, &pListOfExplicitEntries);
        if (dwError != ERROR_SUCCESS){
                printf("GetExplicitEntriesFromAcl failed with error : %u\n\n", dwError);
                return;
        }

        printf("cCountOfExplicitEntries : %d\n", cCountOfExplicitEntries);
        printf("******\n");

        for(ULONG i=0; i<cCountOfExplicitEntries;i++){
                printf("++++++\n");
                switch (pListOfExplicitEntries[i].Trustee.TrusteeForm){
                        case TRUSTEE_IS_SID:
                                printf("TRUSTEE_IS_SID\n");
                                break;
                        case TRUSTEE_IS_NAME:
                                printf("TRUSTEE_IS_NAME\n");
                                //printf("Name: %s\n", pListOfExplicitEntries[i].Trustee.ptstrName);
                                break;
                }

                printf("++++++\n");
                switch (pListOfExplicitEntries[i].Trustee.TrusteeType){
                        case TRUSTEE_IS_USER:
                                printf("TRUSTEE_IS_USER\n");
                                break;
                        case TRUSTEE_IS_GROUP:
                                printf("TRUSTEE_IS_GROUP\n");
                                break;
                        case TRUSTEE_IS_DOMAIN:
                                printf("TRUSTEE_IS_DOMAIN\n");
                                break;
                        case TRUSTEE_IS_ALIAS:
                                printf("TRUSTEE_IS_ALIAS\n");
                                break;
                        case TRUSTEE_IS_INVALID:
                                printf("TRUSTEE_IS_INVALID\n");
                                break;
                        case TRUSTEE_IS_UNKNOWN:
                                printf("TRUSTEE_IS_UNKNOWN\n");
                                break;
                }

                TCHAR account[1000];       
                TCHAR domain[1000];
                DWORD AccountBufflength = 1000;
                DWORD DomainBufflength = 1000;
                PSID_NAME_USE peUse = new SID_NAME_USE;
                PSID Sid = pListOfExplicitEntries[i].Trustee.ptstrName;       
                LookupAccountSid(NULL, Sid, account, &AccountBufflength,domain,&DomainBufflength,peUse);
                _tprintf(TEXT("%s\\%s\n"), domain, account);

marco93 Jan 8th, 2009 12:24 pm
Re: ACL TRUSTEE_TYPE is always Unknown.
 
It's a wrong method.
Ask on Adv. Win32 api newsgroup
news://comp.os.ms-windows.programmer.win32
for the well-known right method...


All times are GMT -4. The time now is 9:34 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC