Article ID: 140964
Article Last Modified on 11/20/2006
228991 How to create and install an SSL certificate in Internet Information Server 4.0
299525 How to set up SSL by using IIS 5.0 and Certificate Server 2.0
298805 How to enable SSL for all customers who interact with your Web site in Internet Information Services
// This will fail with ERROR_INSUFFICIENT_BUFFER,
// since we supplied NULL buffer. As a result, dwLength will
// indicate the size of the buffer to allocate
if (!pECB -> GetServerVariable (pECB -> ConnID,
"REMOTE_USER",
NULL,
&dwLength) )
{
// Handle error other then ERROR_INSUFFICIENT_BUFFER here.
}
lpszVar= (CHAR *) LocalAlloc (LPTR, dwLen);
if ( !pECB -> GetServerVariable (pECB -> ConnID,
"REMOTE_USER",
lpszVar,
&dwLength))
{
// Handle error here
}
The user password can only be retrieved when Basic authentication scheme is
used. The password is not available with the Windows NT Challenge/Response
scheme, because the password never gets transmitted on the network.
Basic xxxxxxxxxxxxxxxwhere Basic is an authentication scheme used, then it is followed by a space, and "xxxxxxxxxxxxxxx" is Base 64 string for "User-Name:User- Password" pair separated by the semicolon.
191239 Sample Base 64 Encoding and Decoding
typedef struct _HTTP_FILTER_AUTHENT
{
CHAR * pszUser;
DWORD cbUserBuff;
CHAR * pszPassword;
DWORD cbPasswordBuff;
} HTTP_FILTER_AUTHENT, *PHTTP_FILTER_AUTHENT;
#define SF_NOTIFY_AUTH_COMPLETE 0x04000000
typedef struct _HTTP_FILTER_AUTH_COMPLETE_INFO
{
//
// For SF_NOTIFY_AUTH_COMPLETE, retrieves the specified header value.
// Header names should include the trailing ':'. The special values
// 'method', 'url' and 'version' can be used to retrieve the individual
// portions of the request line
//
BOOL (WINAPI * GetHeader) (
struct _HTTP_FILTER_CONTEXT * pfc,
LPSTR lpszName,
LPVOID lpvBuffer,
LPDWORD lpdwSize
);
//
// Replaces this header value to the specified value. To delete a header,
// specified a value of '\0'.
//
BOOL (WINAPI * SetHeader) (
struct _HTTP_FILTER_CONTEXT * pfc,
LPSTR lpszName,
LPSTR lpszValue
);
//
// Adds the specified header and value
//
BOOL (WINAPI * AddHeader) (
struct _HTTP_FILTER_CONTEXT * pfc,
LPSTR lpszName,
LPSTR lpszValue
);
//
// Get the authenticated user impersonation token
//
BOOL (WINAPI * GetUserToken) (
struct _HTTP_FILTER_CONTEXT * pfc,
HANDLE * phToken
);
//
// Status code to use when sending response
//
DWORD HttpStatus;
//
// Determines whether to reset auth if URL changed
//
BOOL fResetAuth;
//
// Reserved
//
DWORD dwReserved;
} HTTP_FILTER_AUTH_COMPLETE_INFO, *PHTTP_FILTER_AUTH_COMPLETE_INFO;
HTTP_FILTER_AUTH_COMPLETE_INFO *AuthComp;
if (NotificationType == SF_NOTIFY_AUTH_COMPLETE)
{
AuthComp = (HTTP_FILTER_AUTH_COMPLETE_INFO *) pvNotification;
pfc->GetServerVariable (pfc, "AUTH_TYPE", szType, &dwSize);
dwSum = dwSize;
szType = new CHAR [dwSize];
if (!pfc->GetServerVariable (pfc, "AUTH_TYPE", szType, &dwSize))
{
wsprintf (szTemp, "Can't get Auth_Type: %d\n", GetLastError());
OutputDebugString (szMessage);
}
dwSize = 0;
pfc->GetServerVariable (pfc,"AUTH_USER", szUser, &dwSize);
szUser = new CHAR [dwSize];
if (!pfc->GetServerVariable (pfc,"AUTH_USER", szUser, &dwSize))
{
wsprintf (szTemp, "Can't get Auth_User: %d\n", GetLastError());
OutputDebugString (szMessage);
}
szMessage = new CHAR [dwSum + 256];
wsprintf (szMessage, "> Auth type: %s Auth user: %s\n", szType, szUser);
OutputDebugString (szMessage);
...
}
For additional information, please see the HTTP protocol spec, available on
Keywords: kbhowto kbnetwork KB140964