Start New Discussion within our Software Development Community

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);
This article has been dead for over six months. Start a new discussion instead.