Solved Security for MS Access with no internet connection

Kayleigh

Member
Local time
Today, 11:38
Joined
Sep 24, 2020
Messages
709
Hi

When building systems I like to secure it with a license so it can't be grabbed by anyone other than the client it was intended for.

To this end I invented a MAC address checking method which only allows pre-approved machines to run the system otherwise it will automatically close down. This little mechanism means that any new machine using the system will need to have its MAC address registered first.

However I just ran into an issue that the code I am using will not work when not connected to the internet. Now I am building a system which will very likely not be connected and I would like to use a similar licensing mechanism.

Can anyone suggest how I can use a unique attribute of the PC to my advantage which will work regardless of internet access please.

My code:
Code:
Public Function getLocalMACAddress() As Variant
    ' get a list of enabled adaptor names and MAC addresses
    ' from msdn.microsoft.com/en-us/library/windows/desktop/aa394217(v=vs.85).aspx
    
    Dim objVMI As Object
    Dim vAdptr As Variant
    Dim objAdptr As Object
    Dim arr() As String
    Dim i As Integer
    
    Set objVMI = GetObject("winmgmts:\\" & "." & "\root\cimv2")
    Set vAdptr = objVMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
    
    For Each objAdptr In vAdptr
        ReDim Preserve arr(i)
        arr(i) = objAdptr.Caption & " " & objAdptr.MACAddress
        i = i + 1
       ' Debug.Print arr(i)
        Debug.Print objAdptr.Caption & " " & objAdptr.MACAddress
    Next objAdptr
    
    getLocalMACAddress = arr
End Function


Public Function getMyAdd() As Boolean
Dim arr As Variant
Dim v As Variant
Dim add As Variant
Dim strSQL As String
Dim rs1 As DAO.Recordset

    arr = getLocalMACAddress()
    On Error GoTo Err
    For Each v In arr
    'Debug.Print v
    add = Replace(Right(CStr(v), 17), ":", "-")
    'Debug.Print add
    Set rs1 = CurrentDb.OpenRecordset("SELECT * FROM tblMacAdd;")
    
    If Not rs1.BOF And Not rs1.EOF Then
        rs1.MoveFirst
        While (Not rs1.EOF)
           ' Debug.Print rs1!macaddress
            If rs1!MACAddress = add Then
                getMyAdd = True
                Exit Function
            End If
            rs1.MoveNext
            
        Wend
    End If

    Next
    
    getMyAdd = False


Err:
Debug.Print Err.Number
Select Case Err.Number
Case 92
Resume Next
Case Else
Resume Next
End Select
    
End Function

And in the load event of the login form:
Code:
    If getMyAdd = False Then
        MsgBox "This software is licensed for the use of Nezer Hatorah only. " & Chr(10) + Chr(13) & "Please contact DEMI Software for help.", vbCritical + vbOKOnly, gtStrAppTitle
        Application.Quit
    Else
        Debug.Print "Recognised mac address"
    End If
 

Users who are viewing this thread

Back
Top Bottom