Control Access application through Web site

JohnPapa

Registered User.
Local time
Today, 02:35
Joined
Aug 15, 2010
Messages
1,117
I have developed an Access application which is installed on client pcs. I need to be able to control whether an Access application on a client's pc runs or not and I sometimes need to take this decision based on unforseen events, like abuse of application etc.

Assuming connection to the Internet for the client pc, I thought of having the application communicate stealthily with a Web site and depending on some value on the Web site to take appropriate action such as prevent user from running the software.

The application can sense whether or not it is connected to the Internet and can even send text messages.

On the specific Web site, I may have a table (hidden) with two columns, the user license id and a boolean indicating whether the user is allowed to run the application or not.

Any ideas on how to go about it?
Thanks
 
What you can do is to get the application to reach out to the website location or a location previously setup and get it to look for a file which is named the same as the licence number of the product. If it finds it it knows that it is legal if it can't then it shuts down.

I did have a working copy of this on my pen drive, however, silly me lost it, along with a load of other precious stuff. Good job it was biometrically protected.
 
David, many thanks for your reply. If for example the client serial number is say "154", I could create a file called 154.txt and upload this on my Web site. Do you know how do I check from within Access for this file?
John
 
I will have to look at my old backups to dig it out for you. In the mean time somemone else may have the syntax.
 
David, if it would be helpful I use

Public Declare Function InternetGetConnectedState Lib "wininet" _
(ByRef dwflags As Long, _
ByVal dwReserved As Long) As Long

to check for connection to Internet
John
 
That would be your first step to establish whether a connection to the internet is in place on the resident pc. The only issue is that unless you only allow access to the application when an internet connection is available then users cannot use the application off line.

What are you going to do in that situation?
 
I will decide on any potential action only in the event where the resident pc has Internet connection. If there is no Internet connection then no action will be taken.

As I mentioned, checking on the Internet connection is no problem. It is the checking for the existence of a specific file that I am having problems with.

John
 
This is the nearest and simplest thing I could find from this website that may help you.

This blindly navigates to a website and retrieves info from it. You could bastardise it to suit your needs.

Let me know how you get on.
 

Attachments

David,

Had a look at what you sent over. Basically, when you click on the button in opens (non-visible) the selected page and then searches within the html to find the data of interest.

I added a number on one of my Web pages and I successfully opened the page and located the number (which could be the serial number of the application). This method should work. I just need to investgate how I can enter the number on the Web page and have it be not visible.

Great help on your part and many thanks,
John
 
What you could do is to look for a piece of script from your website and validate it that way. However for each app sold/deployed you could hard code the string you are looking for. Or you could have some white space that contains licence numbers. Donlt know which software your website is written in but you could also hide the text behind another control/image/etc.
 
darbid, tried your suggestions and it works fine. May be easier to include a file bearing the serial number of the user you want to take some action on.
Will investigate further.

Many thanks,
john
 
darbid, a correction to my earlier comment. I was under the impression that it worked, but after some more investigation I did not manage to make it work.

The code copies a Web file to a local file. It seems to create the local file irrespective of whether the Web file exists or not. I actually want something simpler than copying a Web file to the local file. I merely want to confirm whether a specific Web file exists or not. I will know the exact name of the file and the Web location.

The documentation on xmlhttp is not that abundant so any suggestions would help
Thanks,
John
 
i cannot go into it right now as I am not on a Microsoft PC but what I would do is search for "VBA download a file" or something like that. Then in your code just go as far as checking to make sure the file exists and trap an error when the file does not exist.

If you post something in this thread on Monday it will remind me to look at it again, if someone else has not helped you.
 
darbid,

Per your advice in your latest message, I located Windows API function "URLDownloadToFile", which worked fine. If anyone needs the full code I can post.

Many thanks,
John
 
David, an embarassing question. How do you include text with a scrolling bar in ones reply!!! Could not locate it.
John
 
You first paste the code into the window then highlight the desire code then finally you click on the # icon
 
I created sub subDownloadfile to download the file:

Code:
Public Sub subDownloadFile()
Dim strURL As String
Dim strLocalFileName As String
Dim blnDum As Boolean
Dim strErrorText As String
URL =[URL]http://yourdomainname/YourFilePathname[/URL] 
blnDum = DownloadFile(UrlFileName:=strURL, _
DestinationFileName:=strLocalFileName, _
Overwrite:=OverwriteRecycle, _
ErrorText:=strErrorText)
If blnDum = True Then
MsgBox "Found file and downloaded it"
'Kill LocalFileName
'Take appropriate action
Else
MsgBox "Did not find file"
'Take appropriate action
End If
End Sub

I found the following code from the Web.

The Overwrite parameter of DownloadFile indicates how to handle the case when LocalFileName already exists. It is one of the following values:
OverwriteKill use Kill to delete the existing file.
OverwriteRecycle send the existing file to the Recycle Bin.
DoNotOverwrite do not overwrite and terminate the procedure.
PromptUser prompt the user asking whether to overwrite file.

The declarations and other subs/functions are as follows:

Code:
Public Enum DownloadFileDisposition
OverwriteKill = 0
OverwriteRecycle = 1
DoNotOverwrite = 2
PromptUser = 3
End Enum
 
' Windows API functions, constants,and types.
' Used for RecycleFile.
Private Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Declare Function PathIsNetworkPath Lib "shlwapi.dll" _
Alias "PathIsNetworkPathA" ( _
ByVal pszPath As String) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" _
Alias "GetSystemDirectoryA" ( _
ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
Private Declare Function SHEmptyRecycleBin _
Lib "shell32" Alias "SHEmptyRecycleBinA" _
(ByVal hwnd As Long, _
ByVal pszRootPath As String, _
ByVal dwFlags As Long) As Long
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Private Const MAX_PATH As Long = 260
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
 
' Download API function.
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
 
' DownloadFile
' This downloads a file from a URL to a local filename.
Public Function DownloadFile(UrlFileName As String, _
DestinationFileName As String, _
Overwrite As DownloadFileDisposition, _
ErrorText As String) As Boolean
Dim Disp As DownloadFileDisposition
Dim Res As VbMsgBoxResult
Dim B As Boolean
Dim S As String
Dim L As Long
ErrorText = vbNullString
If Dir(DestinationFileName, vbNormal) <> vbNullString Then
Select Case Overwrite
Case OverwriteKill
On Error Resume Next
Err.Clear
Kill DestinationFileName
If Err.Number <> 0 Then
ErrorText = "Error Kill'ing file '" & DestinationFileName & "'." & vbCrLf & Err.Description
DownloadFile = False
Exit Function
End If

Case OverwriteRecycle
On Error Resume Next
Err.Clear
B = RecycleFileOrFolder(DestinationFileName)
If B = False Then
ErrorText = "Error Recycle'ing file '" & DestinationFileName & "." & vbCrLf & Err.Description
DownloadFile = False
Exit Function
End If

Case DoNotOverwrite
DownloadFile = False
ErrorText = "File '" & DestinationFileName & "' exists and disposition is set to DoNotOverwrite."
Exit Function

'Case PromptUser
Case Else
S = "The destination file '" & DestinationFileName & "' already exists." & vbCrLf & _
"Do you want to overwrite the existing file?"
Res = MsgBox(S, vbYesNo, "Download File")
If Res = vbNo Then
ErrorText = "User selected not to overwrite existing file."
DownloadFile = False
Exit Function
End If
B = RecycleFileOrFolder(DestinationFileName)
If B = False Then
ErrorText = "Error Recycle'ing file '" & DestinationFileName & "." & vbCrLf & Err.Description
DownloadFile = False
Exit Function
End If
End Select
End If
L = URLDownloadToFile(0&, UrlFileName, DestinationFileName, 0&, 0&)
If L = 0 Then
DownloadFile = True
Else
ErrorText = "Buffer length invalid or not enough memory."
DownloadFile = False
End If

End Function

Private Function RecycleFileOrFolder(FileSpec As String) As Boolean
Dim FileOperation As SHFILEOPSTRUCT
Dim lReturn As Long
If (Dir(FileSpec, vbNormal) = vbNullString) And _
(Dir(FileSpec, vbDirectory) = vbNullString) Then
RecycleFileOrFolder = True
Exit Function
End If
With FileOperation
.wFunc = FO_DELETE
.pFrom = FileSpec
.fFlags = FOF_ALLOWUNDO
' Or
.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION
End With
lReturn = SHFileOperation(FileOperation)
If lReturn = 0 Then
RecycleFileOrFolder = True
Else
RecycleFileOrFolder = False
End If
End Function
 
 
 

Users who are viewing this thread

Back
Top Bottom