CustomAuth modification to use user identities from an INI file


I recently got the following question about CustomAuth behavior:


Question:


Dear Mr. Wang,


I have read in one of your previous posts that you had posted instructions on how to set up CustomAuth to read usernames and passwords from a text file. Alas, I have not been able to locate this post. Would it be possible for you to point me in the right direction or email the sample if you have it handy?


Best regards,


Ryan


Answer:


Ok, I found that post, made on July 8, 2004 to microsoft.public.inetserver.iis newsgroup. I have cut/paste the relevant portion below.


What you should be aware is that you can also wildcard scriptmap ASP.Net 2.0 on IIS6 and use its excellent membership/roles system to do way better Custom Auth without needing to do this code modification. The caveat is that this inserts managed code into your request pipeline whereas it is not there with CustomAuth.


—–>8———->8———->8———->8———->8———->8———->8—–


Now, with IIS6, we have a custom authentication sample ISAPI that should work for you after you write a little bit of C code to customize it for your specific needs.


Download the Platform SDK and get the IIS portion.  The sample code is called CustomAuth, and the Platform SDK includes necessary tools/compiler to build it (if you do not have Visual Studio or comparable development tool).


http://www.microsoft.com/msdownload/platformsdk/sdkupdate/default.htm


It can be configured for any URL namespace, and it implements custom authentication where you enter username/password in an HTML page.  So, you can easily configure CustomAuth to protect only content under the /Files vdir and no-where else.  The CustomAuth.INI file explains how to do this, conceptually.  Basically, the /Files vdir will have only anonymous authentication enabled and this CustomAuth module loaded to implement custom authentication.


What you’d need to do with this sample code is to implement verification of the username/password entered from the HTML page as well as set the user token for IIS to impersonate — which is EXACTLY all you’re trying to do in the ASP page.


You will find in CustomAuth.cpp a single line containing “LogonUser”, and this is where you’ll inject your code.



  • pstrUser->QueryStr()  contains the username from the form:
  • strPassword.QueryStr()   contains the password from the form
  • The hToken that is created by the LogonUser call is the impersonation
    token that will be used by IIS to execute the subsequent request.

So, all you need to do is:



  1. implement a username/password validation scheme using the values from
    pstrUser and strPassword.  If there’s not a lot of users, I suggest using an
    INI file — one single call to GetPrivateProfileString  should be sufficient
    to lookup a username/password inside a plain-text INI file.
  2. hardcode the LogonUser call to log in UserX
  3. If username/password authenticates, then make the LogonUser call in #2
    let the rest of the code use the hToken for UserX.  If the username/password
    fails to authenticate, then set fResult to FALSE and you’re done.

Here’s a code snippet for you to get started in CustomAuth.cpp.  I haven’t compiled nor tested it, but it should get you most of the way there.


For example, suppose your INI file containing usernames/passwords are in C:\passwords.txt  (make sure that this file is accessible to the anonymous user configured in IIS, since it’s the user identity used to execute the
CustomAuth code.


passwords.txt looks like:


[passwords]
user1=password1
user2=password2


The code snippet looks something like this (I’ve added leading/trailing comments so it is clear where to inject this bit of code in CustomAuth.cpp):

//
// Log on the user
//

DWORD   dwPasswordSize;
CHAR    szStoredPassword[MAX_PATH];

//
// lookup the username key under the “passwords” section
// user passwords are limited to MAX_PATH-1 in length.
// Read MSDN to figure out how to allow larger passwords
//
dwPasswordSize = GetPrivateProfileString(
    “passwords”,
    pstrUser->QueryStr(),
    “”,
    szStoredPassword,
    MAX_PATH,
    “C:\\passwords.txt” );

if ( dwPasswordSize == 0 )
{
    //
    // Did not find username in password.txt, so deny access
    //
    fResult = FALSE;
    SetLastError( ERROR_NO_SUCH_USER );
}
else if ( strcmp( strPassword.QueryStr(), szStoredPassword ) == 0 )
{
    //
    // The password from the form matches password for
    // username in password.txt, so allow access
    // with impersonation token of UserX
    //
    fResult = LogonUser( “UserX”,
                         NULL,
                         “UserX’s password”,
                         g_LogonType,
                         LOGON32_PROVIDER_DEFAULT,
                         &hToken );
}
else
{
    //
    // username was found, but password did not match,
    // so deny access
    //
    fResult = FALSE;
    SetLastError( ERROR_INVALID_PASSWORD );
}

//
// Regardless of the result, we are done with the password
//

Good luck.


//David

Comments (7)

  1. David Wang says:

    People frequently ask about the "Referer Authentication" custom protocol that Apache offers with a custom…

  2. James says:

    Greate site. Thank you :)

  3. James Huang says:

    Hi, David,

    I have downloaded the latest Microsoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0CustomAuth.  While I tried to build it with VC++6.0, I got 112 errors.  Is there anything I am missing?  Thanks!

    James

    ————————————————–

    Compiling…

    CustomAuth.cpp

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(81) : error C2061: syntax error : identifier ‘HSE_EXEC_URL_USER_INFO’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(211) : error C2065: ‘HSE_EXEC_URL_INFO’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(211) : error C2146: syntax error : missing ‘;’ before identifier ‘ExecUrlInfo’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(211) : error C2065: ‘ExecUrlInfo’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(212) : error C2065: ‘HSE_EXEC_URL_USER_INFO’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(212) : error C2146: syntax error : missing ‘;’ before identifier ‘UserInfo’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(212) : error C2065: ‘UserInfo’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(212) : error C2059: syntax error : ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(212) : error C2143: syntax error : missing ‘;’ before ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(212) : error C2143: syntax error : missing ‘;’ before ‘}’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(409) : error C2228: left of ‘.pszUrl’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(410) : error C2228: left of ‘.pszMethod’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(411) : error C2228: left of ‘.pszChildHeaders’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(412) : error C2228: left of ‘.pUserInfo’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(413) : error C2228: left of ‘.pEntity’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(414) : error C2228: left of ‘.dwExecUrlFlags’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(414) : error C2065: ‘HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(418) : error C2228: left of ‘.pUserInfo’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(430) : error C2228: left of ‘.hImpersonationToken’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(440) : error C2065: ‘HSE_REQ_EXEC_URL’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(464) : error C2228: left of ‘.hImpersonationToken’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(466) : error C2228: left of ‘.hImpersonationToken’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(467) : error C2228: left of ‘.hImpersonationToken’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(513) : error C2065: ‘HSE_EXEC_URL_STATUS’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(513) : error C2146: syntax error : missing ‘;’ before identifier ‘ExecUrlStatus’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(513) : error C2065: ‘ExecUrlStatus’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(531) : error C2065: ‘HSE_REQ_GET_EXEC_URL_STATUS’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(536) : error C2228: left of ‘.uHttpStatusCode’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1068) : error C2061: syntax error : identifier ‘HSE_EXEC_URL_USER_INFO’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1161) : error C2065: ‘pstrUser’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1195) : error C2227: left of ‘->QueryStr’ must point to class/struct/union

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1213) : error C2227: left of ‘->QueryStr’ must point to class/struct/union

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1235) : error C2227: left of ‘->hImpersonationToken’ must point to class/struct/union

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1236) : error C2227: left of ‘->pszCustomUserName’ must point to class/struct/union

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1236) : error C2227: left of ‘->QueryStr’ must point to class/struct/union

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1237) : error C2227: left of ‘->pszCustomAuthType’ must point to class/struct/union

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1285) : error C2065: ‘DATA_BLOB’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1285) : error C2146: syntax error : missing ‘;’ before identifier ‘ClearBlob’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1285) : error C2065: ‘ClearBlob’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1285) : error C2059: syntax error : ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1285) : error C2143: syntax error : missing ‘;’ before ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1285) : error C2143: syntax error : missing ‘;’ before ‘}’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1286) : error C2146: syntax error : missing ‘;’ before identifier ‘EncryptedBlob’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1286) : error C2065: ‘EncryptedBlob’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1286) : error C2059: syntax error : ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1286) : error C2143: syntax error : missing ‘;’ before ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1286) : error C2143: syntax error : missing ‘;’ before ‘}’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1287) : error C2146: syntax error : missing ‘;’ before identifier ‘EntropyBlob’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1287) : error C2065: ‘EntropyBlob’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1287) : error C2059: syntax error : ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1287) : error C2143: syntax error : missing ‘;’ before ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1287) : error C2143: syntax error : missing ‘;’ before ‘}’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1351) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1352) : error C2228: left of ‘.cbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1354) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1355) : error C2228: left of ‘.cbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1361) : error C2065: ‘CryptProtectData’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1366) : error C2065: ‘CRYPTPROTECT_UI_FORBIDDEN’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1376) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1377) : error C2228: left of ‘.cbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1391) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1393) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1394) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1395) : error C2228: left of ‘.cbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1438) : error C2146: syntax error : missing ‘;’ before identifier ‘ClearData’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1438) : error C2065: ‘ClearData’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1438) : error C2059: syntax error : ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1438) : error C2143: syntax error : missing ‘;’ before ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1438) : error C2143: syntax error : missing ‘;’ before ‘}’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1439) : error C2146: syntax error : missing ‘;’ before identifier ‘EncryptedData’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1439) : error C2065: ‘EncryptedData’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1439) : error C2059: syntax error : ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1439) : error C2143: syntax error : missing ‘;’ before ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1439) : error C2143: syntax error : missing ‘;’ before ‘}’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1440) : error C2146: syntax error : missing ‘;’ before identifier ‘EntropyData’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1440) : error C2065: ‘EntropyData’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1440) : error C2059: syntax error : ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1440) : error C2143: syntax error : missing ‘;’ before ‘{‘

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1440) : error C2143: syntax error : missing ‘;’ before ‘}’

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1462) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1463) : error C2228: left of ‘.cbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1465) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1466) : error C2228: left of ‘.cbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1468) : error C2065: ‘CryptUnprotectData’ : undeclared identifier

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1485) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1551) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1553) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1554) : error C2228: left of ‘.pbData’ must have class/struct/union type

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthcustomauth.cpp(1555) : error C2228: left of ‘.cbData’ must have class/struct/union type

    IsapiBuffer.cpp

    IsapiDebug.cpp

    IsapiExtension.cpp

    IsapiModule.cpp

    IsapiRequest.cpp

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(320) : error C2065: ‘HSE_IO_NODELAY’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1358) : error C2065: ‘HSE_REQ_IS_CONNECTED’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1732) : error C2065: ‘HSE_VECTOR_ELEMENT’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1732) : error C2146: syntax error : missing ‘;’ before identifier ‘Element’

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1732) : error C2065: ‘Element’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1733) : error C2065: ‘HSE_RESPONSE_VECTOR’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1733) : error C2146: syntax error : missing ‘;’ before identifier ‘Vector’

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1733) : error C2065: ‘Vector’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1741) : error C2228: left of ‘.ElementType’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1741) : error C2065: ‘HSE_VECTOR_ELEMENT_TYPE_MEMORY_BUFFER’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1742) : error C2228: left of ‘.pvContext’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1743) : error C2228: left of ‘.cbOffset’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1744) : error C2228: left of ‘.cbSize’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1763) : error C2228: left of ‘.dwFlags’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1763) : error C2065: ‘HSE_IO_FINAL_SEND’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1772) : error C2228: left of ‘.dwFlags’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1772) : error C2065: ‘HSE_IO_CACHE_RESPONSE’ : undeclared identifier

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1779) : error C2228: left of ‘.pszStatus’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1780) : error C2228: left of ‘.pszHeaders’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1791) : error C2228: left of ‘.nElementCount’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1792) : error C2228: left of ‘.lpElementArray’ must have class/struct/union type

    C:Program FilesMicrosoft Platform SDK for Windows Server 2003 R2SamplesWebiisISAPI_6.0srcIsapiRequest.cpp(1834) : error C2065: ‘HSE_REQ_VECTOR_SEND’ : undeclared identifier

    IsapiString.cpp

    IsapiStringW.cpp

    IsapiTime.cpp

    Redir401.cpp

    c:program filesmicrosoft platform sdk for windows server 2003 r2sampleswebiisisapi_6.0customauthredir401.cpp(599) : error C2065: ‘LOGON32_LOGON_NETWORK_CLEARTEXT’ : undeclared identifier

    Error executing cl.exe.

    Creating browse info file…

    CustomAuth.dll – 112 error(s), 0 warning(s)

  4. David.Wang says:

    James – you are compiling with the old include/lib files from VC++6.

    Please reconfigure VC++6 to use the latest include/lib files from the Platform SDK.

    Whenever you see compilers complaining about "undeclared identifier" and you know the code compiles for other people, then you know you must be using old header/lib files somehow.

    I also have instructions on how to do this at this URL:

    http://blogs.msdn.com/david.wang/archive/2005/12/19/HOWTO_Compile_and_Use_my_ISAPI_Code_Samples.aspx

    //David

  5. Svend says:

    "…the Platform SDK includes necessary tools/compiler to build it (if you do not have Visual Studio or comparable development tool)."

    I did a full install of the 2003 SP 1 Platform SDK.  When I attempt to build any of the samples (using nmake), I get an error about ‘cl’ not being found.  Does the SDK come with a C/C++ compiler?

  6. David.Wang says:

    Svend – Did you run the proper SDK setup script to configure your SDK Build Environment commandline.

    If you cannot get it to work, you can try downloading Visual C++ 2005 Express, which is free.

    http://blogs.msdn.com/david.wang/archive/2005/12/19/HOWTO_Compile_and_Use_my_ISAPI_Code_Samples.aspx

    //David

  7. Svend says:

    I ran all the Build Evironment Windows.  Is this what you mean by setup script?  There was no ‘cl.exe’ installed by the SDK that I could find.

    Thanks for the pointer to the VC download.  I installed that and am now able to compile the examples.