|
|
|||||
|
The LOGON function is used to establish a unique identity for a CAS instance with the connection router in a NET SatisFAXtion domain. The domain's connection router provides a name-service, allowing connections between client and server to be made using meaningful names instead of network addresses. The connection router prevents two clients with the same name from being logged on, and it automatically logs off unresponsive clients. Before calling the LOGON function, a CAS instance must be opened using the CAS Open method. The examples below demonstrate acquiring an interface to the CAS API as well as logging on, then logging off from a NET SatisFAXtion domain. Multiple sessions can be opened and closed with a fax server after a logon has been performed, so typically an application would only need to perform the logon steps once. |
|||||
|
XML Interface: |
|||||
| This tag is not used in the CAS XML
Interface. For more information, see
CAS XML Communications
in the CAS XML Interface. |
|||||
| Type | Max Size | Multiple Allowed | |||
| Function | N/A | No | |||
Example #1 (JavaScript/JScript): |
|||||
function LogOn( OpenSessionToo )
{
var CAS_instance;
// Get access to CAS interface and open an instance
if (CAS = new ActiveXObject("CASX.CAS"))
{
if (CAS_instance = CAS.Open(6,"",1000000))
{
var Tl, UniqueName, StatusNum;
// Logon to the connection router
Tl = CAS.New();
CAS.AddTag(Tl,"LOGON","");
UniqueName = "XYZ-"+parseInt(Math.random()*1000000+1000000);
CAS.AddTag(Tl,"LOGON_NAME",UniqueName);
CAS.AddTag(Tl,"DOMAIN_NAME","\\\\CASDEV\\NETSATISFAXTION");
CAS.AddTag(Tl,"PROTOCOL",2); // IP
if (OpenSessionToo)
{
// By providing a remote logon name now, a session with
// the remote will be opened as part of the LOGON
CAS.AddTag(Tl,"REMOTE_LOGON_NAME","NETSATISFAXTION");
}
Tl = CAS.Send(CAS_instance,Tl);
StatusNum = parseInt(CAS.GetTag(Tl,"STATUS_NUM",0));
CAS.Delete(Tl);
if (StatusNum == 0)
{
// The CAS instance is now logged on to the domain's
// connection router. If REMOTE_LOGON_NAME was included
// with the LOGON, then a session is now open with the
// server. We could open/close sessions as needed now
// that we're logged on, but for this example we'll just
// log off.
Tl = CAS.New();
CAS.AddTag(Tl,"LOGOFF","");
Tl = CAS.Send(CAS_instance,Tl);
CAS.Delete(Tl);
}
CAS.Close(CAS_instance);
}
}
} |
|||||
| Example #2 (VBScript): | |||||
Function LogOn( OpenSessionToo )
Dim CAS, cInst, Tl, StatusNum
Set CAS = CreateObject("CASX.CAS")
cInst = CAS.Open(6,"",60000)
If cInst <> 0 Then
Tl = CAS.New()
Call CAS.AddTag(Tl,"LOGON","")
Randomize
Call CAS.AddTag(Tl,"LOGON_NAME","XYZ-" & Int(100000000 * Rnd))
Call CAS.AddTag(Tl,"DOMAIN_NAME","\\CASDEV\NETSATISFAXTION")
Call CAS.AddTag(Tl,"PROTOCOL",2)
If OpenSessionToo <> 0 Then
'By providing a remote logon name now, a session with
'the remote will be opened as part of the LOGON
Call CAS.AddTag(Tl,"REMOTE_LOGON_NAME","NETSATISFAXTION")
End If
Tl = CAS.Send(cInst,Tl)
StatusNum = CAS.GetTag(Tl,"STATUS_NUM",0)
Call CAS.Delete(Tl)
If StatusNum = 0 Then
'The CAS instance is now logged on to the domain's
'connection router. If REMOTE_LOGON_NAME was included
'with the LOGON, then a session is now open with the
'server. We could open/close sessions as needed now
'that we're logged on, but for this example we'll just
'log off.
Tl = CAS.New()
Call CAS.AddTag(Tl,"LOGOFF","")
Tl = CAS.Send(cInst,Tl)
Call CAS.Delete(Tl)
End If
Call CAS.Close(cInst)
End If
End Function
|
|||||
| Example #3 (C++): | |||||
#include <windows.h>
#import <casx.dll>
using namespace CASXLib;
void LogOn(BOOL OpenSessionToo)
{
HRESULT hr;
CLSID class_id;
ICAS *CAS;
CoInitialize(NULL);
if (CLSIDFromProgID(L"CASX.CAS",&class_id) == S_OK)
{
if ((hr = CoCreateInstance(class_id,
NULL,
CLSCTX_INPROC_SERVER,
IID_IUnknown,
(void **)&CAS)) == S_OK)
{
int CAS_instance;
if (CAS_instance = CAS->Open(6,"",1000000))
{
int Tl, StatusNum;
char UniqueName[16];
// Logon to the connection router
Tl = CAS->New();
CAS->AddTag(Tl,"LOGON","");
wsprintf(UniqueName,"XYZ-%.8X",GetTickCount());
CAS->AddTag(Tl,"LOGON_NAME",UniqueName);
CAS->AddTag(Tl,"DOMAIN_NAME","\\\\CASDEV\\NETSATISFAXTION");
CAS->AddTag(Tl,"PROTOCOL","2"); // IP
if (OpenSessionToo)
{
// By providing a remote logon name now, a session with
// the remote will be opened as part of the LOGON
CAS->AddTag(Tl,"REMOTE_LOGON_NAME","NETSATISFAXTION");
}
Tl = CAS->Send(CAS_instance,Tl);
StatusNum = atoi(CAS->GetTag(Tl,"STATUS_NUM",0));
CAS->Delete(Tl);
if (StatusNum == 0)
{
// The CAS instance is now logged on to the domain's
// connection router. If REMOTE_LOGON_NAME was included
// with the LOGON, then a session is now open with the
// server. We could open/close sessions as needed now
// that we're logged on, but for this example we'll just
// log off.
Tl = CAS->New();
CAS->AddTag(Tl,"LOGOFF","");
Tl = CAS->Send(CAS_instance,Tl);
CAS->Delete(Tl);
}
CAS->Close(CAS_instance);
}
CAS->Release();
}
}
CoUninitialize();
}
|
|||||
| See Also: | |||||
| CAS Open, CAS Send, CAS Close, LOGOFF, OPEN_SESSION, CLOSE_SESSION, PROTOCOL | |||||
|
|