Click here to Skip to main content
15,887,427 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to change the color of message box Pin
David Crow31-Oct-07 2:29
David Crow31-Oct-07 2:29 
QuestionCursor help: [modified] Pin
Hakan Bulut31-Oct-07 0:41
Hakan Bulut31-Oct-07 0:41 
AnswerRe: Cursor help: Pin
Karismatic31-Oct-07 0:55
Karismatic31-Oct-07 0:55 
GeneralRe: Cursor help: Pin
Hakan Bulut31-Oct-07 1:04
Hakan Bulut31-Oct-07 1:04 
GeneralRe: Cursor help: Pin
Roger Broomfield31-Oct-07 1:39
Roger Broomfield31-Oct-07 1:39 
GeneralRe: Cursor help: Pin
Mark Salsbery31-Oct-07 5:30
Mark Salsbery31-Oct-07 5:30 
GeneralRe: Cursor help: Pin
Hakan Bulut31-Oct-07 6:39
Hakan Bulut31-Oct-07 6:39 
QuestionISAPI filter authentication Pin
imazing10331-Oct-07 0:40
imazing10331-Oct-07 0:40 
Hi,
I've written a simple ISAPI filter which would require the user to authenticate before accessing a particular resource. The user will be sent a 401 Unauthorized error and will have to authenticate himself. The username and password have been hardcoded and will be checked against what the user enters in the authentication dialog box. The problem here is , I'm not able to retrieve the username and password that has been entered by the user. I don't know if they are encoded or encrypted. ie I get a " ‹ÿU‹ìì([ " for the values of both pszUser and pszPassword.

How do i retrieve the values ?
Code:

#include <stdio.h>
#include <httpext.h>
#include <httpfilt.h>
#include <string.h>

#define USERNAME "user"
#define PASSWORD "pass"
#define DOMAIN   "domainname"

/* This function is called when the filter is loaded by the web server */
BOOL WINAPI
GetFilterVersion( HTTP_FILTER_VERSION *pVer )
{
  /*  Set the filter version */
  pVer->dwFilterVersion = HTTP_FILTER_REVISION;

  /*  Set a description string for this filter */
  strncpy(pVer->lpszFilterDesc, "Basic Authentication Filter", SF_MAX_FILTER_DESC_LEN);

  /*  Ask to be notified at the authentication stage of every HTTP request */
  pVer->dwFlags = SF_NOTIFY_PREPROC_HEADERS;

  return TRUE;
}


/*  This function is called for every HTTP request */
DWORD WINAPI
HttpFilterProc( PHTTP_FILTER_CONTEXT pfc,
		DWORD notificationType,
		VOID *pvNotification )
{
  HTTP_FILTER_AUTHENT *auth = (HTTP_FILTER_AUTHENT *) pvNotification;
  char domain[256];
  char user[256];

 if( auth->pszUser[0] == '\0') {
    char domain[256];
    OutputDebugString("No user/password given");

    sprintf(domain, "WWW-Authenticate: Basic realm=\"%s\"\r\n", DOMAIN);
	pfc->ServerSupportFunction( pfc, SF_REQ_SEND_RESPONSE_HEADER,
			      (PVOID)   "401 Unauthorized",
			      (DWORD) domain,
			      (DWORD) NULL );

  	return SF_STATUS_REQ_FINISHED;
  }


OutputDebugString(USERNAME);
OutputDebugString(auth->pszUser);
OutputDebugString(auth->pszPassword);

if( strcmp( auth->pszUser, USERNAME ) && strcmp( auth->pszPassword, PASSWORD ) ) {
    char domain[256];
    OutputDebugString("Username or password wrong");
	sprintf(domain, "WWW-Authenticate: Basic realm=\"%s\"\r\n", DOMAIN);
	pfc->ServerSupportFunction( pfc, SF_REQ_SEND_RESPONSE_HEADER,
			      (PVOID)   "401 Unauthorized",
			      (DWORD) domain,
			      (DWORD) NULL );
    return SF_STATUS_REQ_FINISHED;
  }

   
  if( !strcmp( auth->pszUser, USERNAME ) && !strcmp( auth->pszPassword, PASSWORD ) ) {
  OutputDebugString("All conditions satisfied");
  sprintf(domain, "WWW-Authenticate: Basic realm=\"%s\"\r\n", DOMAIN);
  pfc->ServerSupportFunction( pfc, SF_REQ_SEND_RESPONSE_HEADER,
			      (PVOID)   "200 OK",
				  (DWORD) domain,
			      (DWORD) NULL );

  return SF_STATUS_REQ_HANDLED_NOTIFICATION;
}

 return SF_STATUS_REQ_HANDLED_NOTIFICATION;
}



imazing

QuestionToltip for Combo Box Pin
sheshidar31-Oct-07 0:01
sheshidar31-Oct-07 0:01 
AnswerRe: Toltip for Combo Box Pin
Paresh Chitte31-Oct-07 1:56
Paresh Chitte31-Oct-07 1:56 
GeneralRe: Toltip for Combo Box Pin
sheshidar31-Oct-07 2:22
sheshidar31-Oct-07 2:22 
GeneralRe: Toltip for Combo Box Pin
David Crow31-Oct-07 2:31
David Crow31-Oct-07 2:31 
GeneralRe: Toltip for Combo Box Pin
sheshidar31-Oct-07 4:37
sheshidar31-Oct-07 4:37 
QuestionReg Dll Pin
john563231-Oct-07 0:00
john563231-Oct-07 0:00 
AnswerRe: Reg Dll Pin
CPallini31-Oct-07 1:01
mveCPallini31-Oct-07 1:01 
AnswerRe: Reg Dll Pin
Karismatic31-Oct-07 1:02
Karismatic31-Oct-07 1:02 
AnswerRe: Reg Dll Pin
Paresh Chitte31-Oct-07 2:05
Paresh Chitte31-Oct-07 2:05 
Questionhow to save the messages from mobile to PC Pin
pushkar_j31-Oct-07 0:00
pushkar_j31-Oct-07 0:00 
QuestionHi All, I have to write a code in VC++ , to convert *.ppt file to *.jpg file,can you tell me how can i do it????? Pin
anchorwang30-Oct-07 23:56
anchorwang30-Oct-07 23:56 
AnswerRe: Hi All, I have to write a code in VC++ , to convert *.ppt file to *.jpg file,can you tell me how can i do it????? Pin
Karismatic31-Oct-07 1:06
Karismatic31-Oct-07 1:06 
AnswerRe: Hi All, I have to write a code in VC++ , to convert *.ppt file to *.jpg file,can you tell me how can i do it????? Pin
David Crow31-Oct-07 2:50
David Crow31-Oct-07 2:50 
GeneralRe: Hi All, I have to write a code in VC++ , to convert *.ppt file to *.jpg file,can you tell me how can i do it????? Pin
anchorwang31-Oct-07 16:14
anchorwang31-Oct-07 16:14 
GeneralRe: Hi All, I have to write a code in VC++ , to convert *.ppt file to *.jpg file,can you tell me how can i do it????? Pin
David Crow1-Nov-07 2:40
David Crow1-Nov-07 2:40 
QuestionToolTip for comboBox Pin
sheshidar30-Oct-07 23:56
sheshidar30-Oct-07 23:56 
QuestionVirtual function & VPTR issue Pin
Neo Andreson30-Oct-07 23:52
Neo Andreson30-Oct-07 23:52 

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.