예제 #1
0
void DumpAccessToken(CAccessToken& at)
{
	CIndent scope;

	CSid sidUser;
	if (!at.GetUser(&sidUser))
		Log(_T("Failure retrieving User from Token"));
	else
	{
		Log(_T("User:"******"Failure retrieving Groups from Token"));
	else
	{
		Log(_T("Groups:"));
		DumpGroups(groups);
	}

	CTokenPrivileges priv;
	if (!at.GetPrivileges(&priv))
		Log(_T("Failure retrieving Privileges from Token"));
	else
	{
		Log(_T("Privileges:"));
		DumpPrivileges(priv);
	}

	CSid sidOwner;
	if (!at.GetOwner(&sidOwner))
		Log(_T("Failure retrieving Owner from Token"));
	else
	{
		Log(_T("Default Owner:"));
		DumpSid(sidOwner);
	}

	CSid sidPrimaryGroup;
	if (!at.GetOwner(&sidPrimaryGroup))
		Log(_T("Failure retrieving Primary Group from Token"));
	else
	{
		Log(_T("Primary Group:"));
		DumpSid(sidPrimaryGroup);
	}

	CDacl dacl;
	if (!at.GetDefaultDacl(&dacl))
		Log(_T("Failure retrieving Default Dacl from Token"));
	else
	{
		Log(_T("Default Dacl:"));
		DumpAcl(dacl, mapGenericAccess);
	}

	TOKEN_SOURCE source;
	if (!at.GetSource(&source))
		Log(_T("Failure retrieving Source from Token"));
	else
	{
		Log(_T("Source:"));
		Log(_T("Source Name: %.8s"), CString(source.SourceName));
		Log(_T("Source Identifier: 0x%.8x%.8x"), source.SourceIdentifier.HighPart, source.SourceIdentifier.LowPart);
	}

	TOKEN_TYPE type;
	if (!at.GetType(&type))
		Log(_T("Failure retrieving Type from Token"));
	else
		Log(_T("Type: %s"), (LPCTSTR)GetTokenType(type));
	
	if (type == TokenImpersonation)
	{
		SECURITY_IMPERSONATION_LEVEL sil;
		if (!at.GetImpersonationLevel(&sil))
			Log(_T("Failure retrieving Impersonation Level from Token"));
		else
			Log(_T("Impersonation Level: %s"), (LPCTSTR)GetImpersonationLevel(sil));
	}

	TOKEN_STATISTICS stats;
	if (!at.GetStatistics(&stats))
		Log(_T("Failure retrieving Statistics from Token"));
	else
	{
		Log(_T("Statistics:"));
		DumpStatistics(stats);
	}
}