Make a separate program that only you can use. In this program, you'll add the user to the server which will be allowed by our main application.
First add these subs in the program. These will make random serials / keys:
Private Function RandomString(
ByVal size
As Integer ,
ByVal lowerCase
As Boolean )
As String
Dim builder
As New StringBuilder()
Dim random
As New Random()
Dim ch As Char
Dim i
As Integer
For i
= 0
To size
- 1
ch = Convert.ToChar(Convert.ToInt32((26
* random.NextDouble()
+ 65)))
builder.Append(
ch )
Next
If lowerCase
Then
Return builder.ToString().ToLower()
End If
Return builder.ToString()
End Function
Private Function RandomNumber(
ByVal min
As Integer ,
ByVal max
As Integer )
As Integer
Dim random
As New Random()
Return random.
Next (min,max)
End Function
Then create a new sub and add the following code in it:
Dim x
As String = My.Computer.FileSystem.GetTempFileName()
& Rnd()
* 77777999
My.Computer.Network.DownloadFile(
"http://www.yourwebsite.com/Lolland/Serials.txt",x,
"",
"",
False ,1000000,
True )
Dim s As String = "User:" & TextBox1.Text
& vbCrLf
& "Serial:" & RandomString(6,
True )
& "x" & RandomNumber(1,10000000)
My.Computer.FileSystem.WriteAllText(x,vbCrLf
& s ,
True )
My.Computer.Network.UploadFile(x,
"ftp:/
rwebsite.com/Lolland/Serials.txt",
"username",
"password",
False ,1000000,FileIO.UICancelOption.DoNothing)
My.Computer.FileSystem.DeleteFile(x,FileIO.UIOptio n.OnlyErrorDialogs,FileIO.RecycleOption.DeletePerm anently,FileIO.UICancelOption.DoNothing)
Replace yourwebsite with your FTP website details. Uptill now you'll add the username to your database.
Now on the load event of the main form (Of the application that user will use. I mean the main application), add the following:
Dim authenticated
As Boolean = False
Dim file
As String = "http://www.yourwebsite.com/Lolland/Serials.txt"
Dim x
As String = My.Computer.FileSystem.GetTempFileName()
& Rnd()
* 77777999
My.Computer.Network.DownloadFile(file,x,
"",
"",
False ,1000000,
True )
Dim c As String = My.Computer.FileSystem.ReadAllText(file)
For Each n As String In c .Split(vbCrLf)
Dim a()
As String = n .Split(
":")
If a(0)
= vbNullString
Or a(1)
= vbNullString
Then
Continue For
End If
If a(0)
= "User" Then
If Not username.text
= a(1)
Then
MsgBox(
"Username doesn't exist.")
Exit Sub
End If
Else
If Not password.text
= a(1)
Then
MsgBox(
"Password / serial doesn't match. Enter again...")
Exit Sub
Else
authenticated
= True
End If
End If
Next
My.Computer.FileSystem.DeleteFile(x,FileIO.UIOptio n.OnlyErrorDialogs,FileIO.RecycleOption.DeletePerm anently,FileIO.UICancelOption.DoNothing)
If Not authenticated
Then
MsgBox(
"You are not allowed to enter .... blah blah blah...")
Exit Sub
End If
Replace username and password with the textboxes you are using to authenticate. This will download the database file and will see if the details matches. Ask blubb if he can provide you and FTP server. If so, this will work great as your authentication program. Hope this helps.