PDA

View Full Version : Authenticate a user by calling an .exe



jbayog
05-17-2002, 02:00 PM
Does anyone know how to authenticate a user by calling an .exe? The only documentation on authentication illustrates an asp script. I've created an executable and put it out on the web server. In the messages center on the update service, I've given the URL to the exe, but it fails with an error:

User Security

Error: Sorry, Authentication server provided by software vendor is not available. Please try later.

Error returned = 405

Has anyone tried this with success?

Thanks,
Joanne

Sunny's
05-21-2002, 12:52 PM
Running an exe from web server is very generic topic. Answer is depended on type of webserver and platform it is hosted on.

However, if you are using IIS - it is not recommended to run exe from IIS. It has a performance problem, imagine loading exe for each web request.

Recommended way to run compiled code on IIS is either using ISAPI filters which are wrapped as DLL. ISAPI DLL is loaded by IIS and appropriate CGI logic is executed. For more information, please visit - http://msdn.microsoft.com. ISAPI filters can also be configured in different ways to obtain maximum performance.
ASP.NET offers other ways to run compile code.

I have written a small console application which is executed from IIS. In order to prepare for it, remember to give execute permissions as 'Scripts and Executables' in IIS configuration.

This sample code does not address authentication, but it should deliver the message to browser. Here is sample code in C++ MFC based console application:

// TestServer.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "TestServer.h"
#include <atlbase.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
CString input="No QueryString";
char *p = getenv("QUERY_STRING");
if (p) input = p;
int len = input.GetAllocLength() +20;
cout << "HTTP/1.1 200 OK" << endl;
cout << "Content-type: text/html" << endl;
cout << "Content-Length: 29" << endl << endl;;
cout << "<h1>Hello World</h1>" << endl;
cout << "<h2>" << input.GetBuffer(len+1) << "</h2>" << endl;
}

return nRetCode;
}