Solved

Validate License Via Internet from VB App

Posted on 2007-03-30
8
243 Views
Last Modified: 2008-02-01
I have an already existing VB app, that I can modify and add some code, that I wanted to deploy, but need to come up with a solution to validate on-line to allow the application to work. Basically, to validate if a client has paid, let's say, the key would be turned on, and if not, the app key would be turned off.  I can logically create the code, but need some ground-level advice on how and what (and some code) to do this.  What is involved.  Conceptually it seems simple, I have a list of clients, with a flag of 1 or 0 (on/off).  I can update this value at will.  The client app upon runtime, or say every 30 days, goto a designated site, look up the client, see the value, and let it do its thing from there.  Any ideas on what the best approach is, and how to do something like this?  I'm creating a service model for this app.  Thanks!
0
Comment
Question by:rsp05
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 32

Expert Comment

by:Robberbaron (robr)
Comment Utility
1/ need to have a website that is DB enabled.. costs more
1.1 Create a form there that accepts a UserID as input and returns a passcode to the application.  The VB Web controls should be able to do this.
1.2 The application then compares the returned passcode to the locally stored one.
1.3 If you will be tying this to a machine, then you need a mechanism for identifing each box. So the first time and install is done on a PC, the user will have to enter some detail of the box and get back a valid passcode.
1.4 A hardware key would be best for this latter part as it's more secure, a licence can be shared around the office (one at a time though).  Talking dollars though.

2/ If website is not DB & scripting enabled, then you will have to download a textfile, perhaps based upon the userid , open it and compare contents with passcode.
2.1 this is probably a little more difficult to manage but when licence expires, you can change the webfile so the passcode no longer matches.
2.2 I wouldnt just delete the file as then the user will get a "file not found" error which could be just because the internet is don for them.

my 2c worth.
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
Comment Utility

the way i would design it, is not to disable the code,
but to remove the code


if you have some code disabled, or a menu item disabled or so,
this can be easily reverse engineered.

when the code is not there (it is in a dll that sits on your server)

it needs to be downloaded before the user can execute the code.


and when can the user download it?
with the right code :)
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
that would mean that the application could not be used offline!
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
Comment Utility

that would mean the user would validate online, and then the pc can be taken offline
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:rsp05
Comment Utility
Thanks, all for reply.
Mark is right, although I would have the app validated every say, 30 days (+ a grace period), and the app would be used offline.  I would require that the user app have access to the internet.
I will study robberbaron's interesting solutions.

I was going to have the validation code compiled in the vb app, and the client info would be in the registry (where it is now).  What is some code sample to goto a web site, read a file, and compare values. Tx
0
 

Author Comment

by:rsp05
Comment Utility
robberbaron: If I went w/option 2, how would I reference the textfile, just by supplying the path to url?.  I would need to upload a textfile to the site, and call it there?  Code ideas?  Thx
0
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 125 total points
Comment Utility
1/ You would need to assign each user a licence number xxyyzz (no surprise there) when they paid for app.

2/ You upload a Text or binary file to your web server, named like xxyyyzz.lic.  It can be a binary format decided by you and has expiry date etc encoded within.

3/ When user installs app on their system , they enter the license number. App saves to registry.

4/ When app runs, it gets license number from registry then attempts to connect to INET and retrieve the license file xxyyzz.lic from your website.  The app saves the lic file or just opens stream and decodes data.  App then decides if it is currently licensed to run.

5/ When lic expires, you can delete the lic file from web or simply copy an invalid one in its place. I like the latter as the user will then get a License invalid error rather than lic not found.

-------------------------------------------------
Here is some code i once used to download a couple of files from net using the Internet control

    Dim strURL As String, x As CheckBox
    Dim savefile As String, fln As Long
    Dim b() As Byte
   
   
    For Each x In chkGethistory
        If x.Value = vbChecked Then
           
            ' Set the strURL to a valid address.
            Select Case x.index
                Case 0  'Saturday
                    strURL = URLHistorySat
                    savefile = FileHistorySat
                    'picOut.Print "/"
                    picOut.Print "Sat Hist"
                Case 1  'wednay
                    strURL = URLHistoryWed
                    savefile = FileHistoryWed
                    'picOut.Print "/"
                    picOut.Print "Wed Hist"
                Case 2  '
                    'strURL = URLHistoryPball
            End Select
       
             b() = Inet1.OpenURL(strURL, icByteArray)
            picOut.Print "/";
            fln = FreeFile
            Open savefile For Binary Access Write As #fln
            Put #fln, , b()
            Close #fln
            picOut.Print "} saved"

           
        End If

    Next x
0
 

Author Comment

by:rsp05
Comment Utility
robberbaron:  Definately enough to go on.  Appreciate the logic which I am using.  Found some alternate code to accomplish this, but you definately gave me 99% of what I needed - Thanks so much!  I'll post it here for future users:

Private Declare Function URLDownloadToFile Lib "urlmon" _
   Alias "URLDownloadToFileA" _
  (ByVal pCaller As Long, _
   ByVal szURL As String, _
   ByVal szFileName As String, _
   ByVal dwReserved As Long, _
   ByVal lpfnCB As Long) As Long
   
   
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000


Private Sub Form_Load()

   Command1.Caption = "Download File"
   
End Sub

   
Private Sub Command1_Click()

   Dim sSourceUrl As String
   Dim sLocalFile As String
   Dim hfile As Long
   
   sSourceUrl = "http://www.myurl/client1.lic"
   sLocalFile = "c:\localtemp.lic"
   
 
   If DownloadFile(sSourceUrl, sLocalFile) Then
   
      hfile = FreeFile
      Open sLocalFile For Input As #hfile
         msg = Input$(LOF(hfile), hfile)
         MsgBox (msg)
      Close #hfile
     
   End If

End Sub


Public Function DownloadFile(sSourceUrl As String, _
                             sLocalFile As String) As Boolean
 
  'Download the file. BINDF_GETNEWESTVERSION forces
  'the API to download from the specified source.
  'Passing 0& as dwReserved causes the locally-cached
  'copy to be downloaded, if available. If the API
  'returns ERROR_SUCCESS (0), DownloadFile returns True.
   DownloadFile = URLDownloadToFile(0&, _
                                    sSourceUrl, _
                                    sLocalFile, _
                                    BINDF_GETNEWESTVERSION, _
                                    0&) = ERROR_SUCCESS
   
End Function
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now