Click here to Skip to main content
15,904,155 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Trying to create a guid in C++ from my code Pin
David Crow31-Oct-07 2:26
David Crow31-Oct-07 2:26 
AnswerRe: Trying to create a guid in C++ from my code Pin
George L. Jackson31-Oct-07 2:41
George L. Jackson31-Oct-07 2:41 
AnswerRe: Trying to create a guid in C++ from my code Pin
jhwurmbach31-Oct-07 2:30
jhwurmbach31-Oct-07 2:30 
AnswerRe: Trying to create a guid in C++ from my code [modified] Pin
KenThompson31-Oct-07 2:43
KenThompson31-Oct-07 2:43 
GeneralRe: Trying to create a guid in C++ from my code Pin
jhwurmbach31-Oct-07 3:17
jhwurmbach31-Oct-07 3:17 
GeneralRe: Trying to create a guid in C++ from my code Pin
KenThompson1-Nov-07 2:47
KenThompson1-Nov-07 2:47 
QuestionLoad AVI streams with MCIWnd.OpenInterface Pin
sdancer7531-Oct-07 2:04
sdancer7531-Oct-07 2:04 
Questionmaximal number of dialogs Pin
baerten31-Oct-07 1:56
baerten31-Oct-07 1:56 
AnswerRe: maximal number of dialogs Pin
Paresh Chitte31-Oct-07 2:08
Paresh Chitte31-Oct-07 2:08 
GeneralRe: maximal number of dialogs Pin
baerten31-Oct-07 2:16
baerten31-Oct-07 2:16 
AnswerRe: maximal number of dialogs Pin
Shivarudrayya H31-Oct-07 2:17
Shivarudrayya H31-Oct-07 2:17 
AnswerRe: maximal number of dialogs Pin
David Crow31-Oct-07 2:28
David Crow31-Oct-07 2:28 
JokeThanks to you all Pin
baerten31-Oct-07 4:19
baerten31-Oct-07 4:19 
AnswerRe: maximal number of dialogs Pin
Randor 31-Oct-07 4:34
professional Randor 31-Oct-07 4:34 
Questionhow to change the color of message box Pin
rajneshmalik31-Oct-07 1:21
rajneshmalik31-Oct-07 1:21 
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 

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.