ZmeYRRASEnum component

Installtion
Register component using regsvr32 ZmeYRRASEnum.dll.

License
This component is FREEWARE and can be distributed and used without any permission.

General
ZmeYRRASEnum component implements operations related to controling RAS access and control of the dial-in enabled ports on machines running Windows NT with Routing and RAS (RRAS). This causes Windows 2000 too. On Windows NT 4.0 it can be used only for servers running RRAS, on Windows 2000 it can work with any version. The control itself can run on NT 4.0 workstations with SP4 but it can control remotely only NT servers with RRAS running !

Usage
Component name is ZmeYRRASEnum i.e.create component's object as follows:
Server.CreateObject("ZmeYRRASEnum.RRASServer") in ASP pages or
var ras = new ActiveXObject("ZmeYRRASEnum.RRASServer"); in Windows Scripting Host scripts
RRASServer
is the base object that you must create. It establishes connection to the server and creates collection of port objects.

See additional usage notes at the bottom of this document.

Objects

RRASServer You will need one of this objects per every RRAS server managed by your script/application
Properties:
Name access Description
Count; read long - count of RASPort objects in the collection
Item(VARIANT Index) read object - returns RASPort object by Index. Index can be String or numeric value, but can not be object.
Server read/write BSTR - server name. RRAS server that will be managed through this object. Example:
ras.Server = "MYRASSERVER"
IsConnected read long - returns status - 1 if object is connected to the server and 0 if not.
Username read/write BSTR - username of the NT account to be used to establish server connection
Password write BSTR - password for the NT account to be used to establish server connection
Diagnostic properties - not important for typical usage
Diagnostic
Whoami
WhoamiProcess

 

Methods:
Methods of this object are another versions of the Integers and Strings properties 

Name Returns Description
Refresh() void Refreshes values in port collection. Must be called between Connect and Disconnect.
Connect() void Tries to connect to server (switches user context if Username is not empty)
Disconnect() void Disconnects from server
HangUpPort(VARIANT Index) void Disconnects user on port specified by Index. Index can be numeric or string value (Port name).
ResetPort(VARIANT Index) void Resets port hardware specified by Index. Index can be numeric or string value (Port name).
HangUpUser(BSTR Username) long Hangups all connections of user specified, returns count of droped connections.

 

 

RASPort Never create this object directly ! Collection of RASPort objects is created by RRASServer object on connection
Properties:
Name access Description
Name read BSTR - Name of the port
MediaName read BSTR - Media name for this port
DeviceName read BSTR - TAPI device name
DeviceType read BSTR - device type - modem, VPN etc.
Condition read long - condition:
RAS_PORT_NON_OPERATIONAL
The port is not operational.
RAS_PORT_DISCONNECTED
The port is disconnected.
RAS_PORT_CALLING_BACK
The port is in the process of a call-back.
RAS_PORT_LISTENING
The port is listening for incoming calls.
RAS_PORT_AUTHENTICATING
The port is authenticating a user.
RAS_PORT_AUTHENTICATED
The port has authenticated a user.
RAS_PORT_INITIALIZING
The port is initializing.
ConditionName read BSTR - readable text that describes port condition
ConnectDuration read long - duration of current connection in seconds
Username read BSTR - Username of the connected user
Domain read BSTR - Authentication domain of the connected user
RemoteMachine read BSTR - remote machine name (if present)
IP read BSTR - IP address of the connected user
BytesIn read long - bytes received on this port (for current connection)
BytesOut read long - bytes transmited on this port (for current connection)
Speed read long - speed of the connection in bits per second (as detected)

Remarks
RRASServer object must run in the context of the NT account with administrative rights ! So if you going to create ASP pages - those pages will be useful only for the administrators.
RRASServer object supports some switch user capabilities. Setting Username and Password properties you can force object to use specified account for connections. But this trick will not work if your object lives in the already switched context ! Typical usage in ASP pages is a good example for this situation. In WSH scripts context switching works fine because your script will start in your context. To use this features base account (in wich script starts) must have SetTcbName privilege (Act as part of operating system). You can grant privilege using Usermanager, but note that this can be risky in some cases (depending to the security strategy of the system).

Typicaly you will need to call members of the RRASServer object in the following order:
1 - Connect() - to connect to server and create collection of the server ports
2 - Refresh() - to grab current state of ports (Connect will not fill port collection with actual values).
.... Do something with RASPort objects, call other members ....
3 - Disconnect() - end connection to the server.

Package ships with WSH and ASP examples (in JScript)

Sample:

var port;
var str;
ras.Server = "MYSERVER";
ras.Connect();
function StrFormat(text,place) {
    var str1 = new String(text);
    while (str1.length < place) {
        str1 += " ";
    }
    return str1;
}

if (ras.IsConnected == 1) {
	WScript.Echo("Connected to the server: " + ras.Server );
	WScript.Echo(" ");
	str = 	StrFormat("PORT",8);
	str +=	StrFormat("CONDITION",30);
	str +=  StrFormat("USER",20);
	str +=  StrFormat("IP",20);
	WScript.Echo(str);
        ras.Refresh();
        for (i = 1; i <= ras.Count; i++) {
            	port = ras(i);
		str = 	StrFormat(port.Name,8);
		str +=	StrFormat(port.ConditionName,30);
		str +=	StrFormat(port.Username,20);
		str +=	StrFormat(port.IP,20);

		WScript.Echo(str);
	}
}

This WSH sample lists port status on MYSERVER.

 


ZmeY soft 1999

http://www.zmey.com

http://products.zmey.com