Introduction
If you are a .NET programmer, you can easily use a simple API to create your own
database backend and billing software. Just create a .NET DLL with a specific name,
which exposes a required Class.
Evolynx RADIUS server expects to find a Class Library DLL file, named "BusLayer.dll",
in the same directory as "EvolynxRadius.exe" is located. This DLL should expose
a Public Class name "Business" which implements the "IBusiness" interface. This
interface is defined in the "Common.dll" and is used to make sure that you
create a Business class which has all methods required by Evolynx RADIUS.
Business Class
When creating the DLL, you must at least create one class named Business. This Class
is the bridge between Evolynx RADIUS and your billing software. Evolynx RADIUS will
call specific methods of this Class to exchange information with database. A typical
Business Class will look like this:
Imports Evolynx.Radius.Common
Public Class Business
Implements IBusiness
Public Function Authenticate(ByVal Packet As RadiusPacket) As
Integer _
Implements IBusiness.Authenticate
'Here you should check the user credencials
'return values are 0,1,2 for Reject,Accept and
Challenge
End Function
Public Sub AccountingStart(ByVal Packet As RadiusPacket) _
Implements IBusiness.AccountingStart
End Sub
Public Sub AccountingOther(ByVal Packet As RadiusPacket) _
Implements IBusiness.AccountingOther
End Sub
Public Sub AccountingStop(ByVal Packet As RadiusPacket) _
Implements IBusiness.AccountingStop
End Sub
Public Sub OnForwardRequest(ByVal Packet As RadiusPacket, _
ByVal TargetIP As String) _
Implements IBusiness.OnForwardRequest
End Sub
Public Sub OnForwardAccounting(ByVal Packet As RadiusPacket, _
ByVal TargetIP As String) _
Implements IBusiness.OnForwardAccounting
End Sub
Public Sub OnForwardToNAS(ByVal Packet As RadiusPacket, _
ByVal TargetIP As String) _
Implements IBusiness.OnForwardToNAS
End Sub
Public Sub LoadConfig() Implements IBusiness.LoadConfig
End Sub
Public Function LoadClients() As ClientsCollection _
Implements IBusiness.LoadClients
End Sub
Public Function WriteError(ByVal Message As String, _
Optional ByVal ErrorID As Long = 0) As Long
_
Implements IBusiness.WriteError
End Sub
Public Sub NotifyByEmail(ByVal State As Object) _
Implements IBusiness.NotifyByEmail
End Sub
Public Sub ScheduledMaintenance(ByVal State As Object) _
Implements IBusiness.ScheduledMaintenance
End Sub
End Class
Step by Step: How to create BusLayer.dll
Now that we know what we need to create, lets see how it should be created. The
following steps summarize how you can create the DLL using Visual Basic .NET:
- Create a new Class Library Project and name it BusLayer
- In Solution Explorer, right click on References and select "Add Reference"
- On .NET tab, click on Browse and select "Common.dll" which is located in Evolynx
RADIUS directory, and click ok
- Copy the code from this page (inside the box) to your class module
- Add code to any of the methods you want
- When you are finished debugging your DLL, Build and copy your bug free DLL to Evolynx
RADIUS directory (RADIUS Service should be stopped)
How to debug BusLayer.dll
In order to debug your DLL in Visual Studio .NET environment follow these steps:
- Set the "Output Path" of your DLL project to the Evolynx RADIUS directory
- In Solution Explorer window, right click on project and select Properties
- From the folders list at the left side select "Configuration Properties/Build"
- Use the browse button (...) to browse to the Evolynx RADIUS directory
- Click OK
- Make sure EvolynxRADIUS service is stopped
- Build your DLL in Debug mode
- Start the EvolynxRADIUS service
- From Debug menu select Processes
- In the list of available Processes select EvolynxRadius.exe and then Click on Attach
button
- On the next window make sure "Common Language Runtime" is selected then click OK
- Close the Processes window
- Use breakpoints to stop execution in any part of your code
- Use a RADIUS client (or Evolynx RADIUS Load Test Tool) to send requests to RADIUS
Server and test your DLL
Sample Code
We have prepared a very simple example with minimum functionality to show how you
can use the Evolynx API to create a DLL which authenticates users with a MS-Access
database. In order to run this example, you need to re-define the Reference to "Definitions.dll"
and set the "Output Path" in Project Properties. The mdb file must be placed in
Evolynx RADIUS directory.
API Example (VB.NET
2003 source code)
Sample Access mdb
file
How to control Evolynx RADIUS Service
Evolynx RADIUS runs as a Windows service. With some .NET programming you can control
some of the internal functions of this service. To do this, you need to create a
ServiceController object and connect it to Evolynx Service. Then you can start and
Stop the service or run a Custom command. The following sample code shows how to
Start the service and run a Custom Command:
DIM myService As New ServiceProcess.ServiceController()
myService.MachineName = "server-1"
myService.ServiceName = "EvolynxRADIUS"
myService.Start()
myService.ExecuteCommand(131)
Currently there are 4 custom commands defined. These commands are used to reload
settings and information without re-starting the service:
- 130 = Reloads the settings from Config file or from API
- 131 = Reloads the Clients from "clients.txt" file or from API
- 132 = Reloads the Proxy information from "proxy.txt" file
- 133 = Reloads the Dictionary information from "radius.txt" file
- 134 = Clears the logs, both RADIUS.LOG and the database log
|