Solved

Validate License Via Internet from VB App

Posted on 2007-03-30
8
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 18828016
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
ID: 18830851

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 70

Expert Comment

by:Éric Moreau
ID: 18831801
that would mean that the application could not be used offline!
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 18831828

that would mean the user would validate online, and then the pc can be taken offline
0
 

Author Comment

by:rsp05
ID: 18834304
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
ID: 18868608
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
ID: 18874635
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
ID: 18878126
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

726 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