Click here to Skip to main content
15,913,854 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DirectShow Tutorials Pin
GermanGeorge11-May-04 4:02
GermanGeorge11-May-04 4:02 
Questionany articles written about cryptography for beginners?? Pin
FASTian10-May-04 23:21
FASTian10-May-04 23:21 
AnswerRe: any articles written about cryptography for beginners?? Pin
nguyenvhn11-May-04 0:06
nguyenvhn11-May-04 0:06 
GeneralRe: any articles written about cryptography for beginners?? Pin
Miguel Lopes11-May-04 2:32
Miguel Lopes11-May-04 2:32 
AnswerRe: any articles written about cryptography for beginners?? Pin
toxcct11-May-04 0:40
toxcct11-May-04 0:40 
GeneralRe: any articles written about cryptography for beginners?? Pin
FASTian12-May-04 0:28
FASTian12-May-04 0:28 
GeneralOutlook Express API Pin
Ajay Vijayvargiya10-May-04 23:08
Ajay Vijayvargiya10-May-04 23:08 
GeneralISAPI FILTER ON A ISA SERVER Pin
SuzannaS10-May-04 23:04
SuzannaS10-May-04 23:04 
Hi,
I'm developping an ISAPI FILTER that whill be installed on a ISA SERVER. This ISAPI filter should handle the following action for each client which wants to connect to Internet:

1. Gets the user name and the URL of the site to which he or she wanted to navigate
2. redirect any request to an Intranet site which shows a simple Web page with some warnings and also the link to the site to which the user wanted to connect
3. the user can then click on the link and navigate wherever he/she likes

The redirection should happen at the beginning of any network session. Is it true that a network session can contain many session requests??

Where can I find some documentation/help?

You can see my actual code as follows: this code only write a log file to see what happens and try to catch the user name on the AUTH_COMPLETE notification and to catch the URL requested on the PREPROC_HEADERS notification: I'm already sure that there is a problem with getting the user name... can anybody help my?:

#include <windows.h>
#include <httpfilt.h>
#include <stdio.h>

#include <iostream>
#include <fstream>

const UINT MAX_NAME = 10;

const char sFileName[] = "c:\\temp\\AIM_FILTER_LOG.txt";

static DWORD OnEndOfNetSession (PHTTP_FILTER_CONTEXT pfc);
static DWORD OnPreprocHeaders (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo);
static DWORD OnReadRawData (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_RAW_DATA pRawData);
static DWORD OnAuthComplete (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_AUTH_COMPLETE_INFO pAuthCompInfo);
static DWORD OnSendResponse (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_SEND_RESPONSE pResponse);
static DWORD OnSendRawData (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_RAW_DATA pRawData);
static DWORD OnEndOfRequest (PHTTP_FILTER_CONTEXT pfc);
static DWORD OnEndOfNetSession (PHTTP_FILTER_CONTEXT pfc);

static DWORD WriteIntoFile(PHTTP_FILTER_CONTEXT pfc, const char *Testo);


BOOL WINAPI TerminateFilter(

DWORD dwFlags
)
{
return TRUE;
}


BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pVer)
{
pVer->dwFilterVersion = HTTP_FILTER_REVISION;

pVer->dwFlags = SF_NOTIFY_ORDER_HIGH | SF_NOTIFY_SECURE_PORT | SF_NOTIFY_NONSECURE_PORT
| SF_NOTIFY_PREPROC_HEADERS | SF_NOTIFY_READ_RAW_DATA | SF_NOTIFY_AUTH_COMPLETE |
SF_NOTIFY_SEND_RESPONSE | SF_NOTIFY_SEND_RAW_DATA |
SF_NOTIFY_END_OF_REQUEST | SF_NOTIFY_END_OF_NET_SESSION;

return TRUE;
}

DWORD WINAPI HttpFilterProc(
PHTTP_FILTER_CONTEXT pfc,
DWORD NotificationType,
LPVOID pvNotification
)
{
DWORD dwRet = SF_STATUS_REQ_NEXT_NOTIFICATION;

switch (NotificationType)
{
case SF_NOTIFY_READ_RAW_DATA:
dwRet = OnReadRawData(pfc, (PHTTP_FILTER_RAW_DATA) pvNotification);
break;
case SF_NOTIFY_PREPROC_HEADERS:
dwRet = OnPreprocHeaders(pfc, (PHTTP_FILTER_PREPROC_HEADERS) pvNotification);
break;
case SF_NOTIFY_AUTH_COMPLETE:
dwRet = OnAuthComplete(pfc, (PHTTP_FILTER_AUTH_COMPLETE_INFO)pvNotification);
break;
case SF_NOTIFY_SEND_RESPONSE:
dwRet = OnSendResponse(pfc, (PHTTP_FILTER_SEND_RESPONSE)pvNotification);
break;
case SF_NOTIFY_SEND_RAW_DATA:
dwRet = OnSendRawData(pfc, (PHTTP_FILTER_RAW_DATA)pvNotification);
break;
case SF_NOTIFY_END_OF_REQUEST:
dwRet = OnEndOfRequest(pfc);
break;
case SF_NOTIFY_END_OF_NET_SESSION:
dwRet = OnEndOfNetSession(pfc);
break;
default:
// We cannot reach here, unless Web Filter support has a BAD ERROR.
dwRet = SF_STATUS_REQ_ERROR;
break;
};

return dwRet;
}


/*
* OnAuthComplete():
*/
static DWORD OnAuthComplete(PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_AUTH_COMPLETE_INFO pAuthCompInfo)
{
HANDLE TokenHandle = (HANDLE)1;
DWORD dwLen = 0;
PTOKEN_USER pTokenUser = NULL;
DWORD dwErr;
char name[MAX_NAME], domain[MAX_NAME];

// Get user token.
if ( pAuthCompInfo->GetUserToken(pfc,&TokenHandle) )
{
// Get token information size.
if ( !GetTokenInformation(TokenHandle,TokenUser,NULL,dwLen,&dwLen) )
{
dwErr = GetLastError();
if ( ERROR_INSUFFICIENT_BUFFER == dwErr )
{
// Alocate buffer for token information.
pTokenUser = (PTOKEN_USER)GlobalAlloc(GPTR,dwLen);
dwErr = S_OK;
}
}

// Now get the actual token information.
if ( dwErr != S_OK ||
!GetTokenInformation(TokenHandle, TokenUser,pTokenUser,dwLen,&dwLen) )
{
// Error …
}
else // We have the token information in hand.
{
// Extract from the token information - the SID.
SID *pSid = (SID *)pTokenUser->User.Sid;
DWORD dwNLen = MAX_NAME, dwDLen = MAX_NAME;
SID_NAME_USE eUse;

// Get the user name and the domain from the SID.
if (!LookupAccountSid(NULL,pSid,name,&dwNLen,domain,&dwDLen,&eUse) )
{
// Error …
}
else
{
// name buffer contains user name.
// domain buffer contains user domain.
}
}
}


if (*name != NULL)
return WriteIntoFile(pfc, "Evento OnAuthComplete: User name:" + *name);
else
return WriteIntoFile(pfc, "Evento OnAuthComplete: ");

return WriteIntoFile(pfc, "Evento OnAuthComplete: ");
}

static DWORD OnPreprocHeaders (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo)
{
char buffer[256];
DWORD buffSize = sizeof(buffer);

BOOL bHeader = pHeaderInfo->GetHeader(pfc, "url", buffer, &buffSize);

//scrive URL nel file
return WriteIntoFile(pfc, "Evento OnPreprocHeaders " + *buffer);
}

/*
* OnReadRawData():
*/
static DWORD OnReadRawData (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_RAW_DATA pRawData)
{
return WriteIntoFile(pfc, "Evento OnReadRawData: ");
}

/*
* OnSendResponse():
*/
static DWORD OnSendResponse (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_SEND_RESPONSE pResponse)
{
return WriteIntoFile(pfc, "Evento OnSendResponse: ");
}

/*
* OnSendRawData():
*/
static DWORD OnSendRawData (PHTTP_FILTER_CONTEXT pfc, PHTTP_FILTER_RAW_DATA pInRawData)
{
return WriteIntoFile(pfc, "Evento OnSendRawData: ");
}

/*
* OnEndOfNetSession():
*/
static DWORD OnEndOfNetSession (PHTTP_FILTER_CONTEXT pfc)
{
return WriteIntoFile(pfc, "Evento OnEndOfNetSession: ");
}

/*
* OnEndOfRequest():
*/
static DWORD OnEndOfRequest (PHTTP_FILTER_CONTEXT pfc)
{
return WriteIntoFile(pfc, "Evento OnEndOfRequest: ");
}


/*
* WriteIntoFile()
*
*/
static DWORD WriteIntoFile(PHTTP_FILTER_CONTEXT pfc, const char *Testo)
{
std::ofstream myFile;
myFile.open(sFileName,std::ios::app);

if(myFile.is_open())
{
myFile << Testo;
myFile << "\n\n";

//myFile.write(Testo,strlen(Testo));
//myFile.flush();
}
else
{
char myString[] = "

Write File Error \n

";
strcat(myString, Testo);
LPBYTE lpBuffer = (LPBYTE)&myString;
DWORD bytesToSend = sizeof myString;
DWORD dwReserved = 0;
pfc->WriteClient(pfc,(LPVOID)lpBuffer,&bytesToSend,dwReserved);
//ErrorHandler("Could not open file."); // process error
return SF_STATUS_REQ_ERROR;
}

myFile.close();

return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
QuestionHow to add callouts Pin
muthukumar_pandian10-May-04 22:52
muthukumar_pandian10-May-04 22:52 
QuestionHow to Load/Save Image in database using VC++ MFC Pin
Sumit Kapoor10-May-04 22:14
Sumit Kapoor10-May-04 22:14 
AnswerRe: How to Load/Save Image in database using VC++ MFC Pin
Maxwell Chen10-May-04 22:21
Maxwell Chen10-May-04 22:21 
GeneralRe: How to Load/Save Image in database using VC++ MFC Pin
Sumit Kapoor10-May-04 22:31
Sumit Kapoor10-May-04 22:31 
GeneralRe: How to Load/Save Image in database using VC++ MFC Pin
Maxwell Chen10-May-04 22:47
Maxwell Chen10-May-04 22:47 
GeneralRe: How to Load/Save Image in database using VC++ MFC Pin
Sumit Kapoor10-May-04 23:00
Sumit Kapoor10-May-04 23:00 
GeneralRe: How to Load/Save Image in database using VC++ MFC Pin
Miguel Lopes11-May-04 0:29
Miguel Lopes11-May-04 0:29 
GeneralRe: How to Load/Save Image in database using VC++ MFC Pin
Maxwell Chen11-May-04 1:29
Maxwell Chen11-May-04 1:29 
GeneralRe: How to Load/Save Image in database using VC++ MFC Pin
Maxwell Chen11-May-04 1:39
Maxwell Chen11-May-04 1:39 
Generalhiding or locking files/folders/drives Pin
kanetheterrible110-May-04 21:33
kanetheterrible110-May-04 21:33 
GeneralRe: hiding or locking files/folders/drives Pin
Monty210-May-04 21:51
Monty210-May-04 21:51 
GeneralRe: hiding or locking files/folders/drives Pin
kanetheterrible111-May-04 6:34
kanetheterrible111-May-04 6:34 
QuestionHow do I get the DSN auth mode in VC++ code Pin
PrashantJ10-May-04 20:56
PrashantJ10-May-04 20:56 
GeneralHelp Regarding MFC Pin
balajeedurai10-May-04 20:44
balajeedurai10-May-04 20:44 
GeneralRe: Help Regarding MFC Pin
Monty210-May-04 21:16
Monty210-May-04 21:16 
GeneralMULTIPLE UNDO Pin
Ventsislav10-May-04 20:19
Ventsislav10-May-04 20:19 
GeneralRe: MULTIPLE UNDO Pin
Maxwell Chen10-May-04 20:34
Maxwell Chen10-May-04 20:34 

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.