Solved

VB Code: blcok access to apps after period of inactivity

Posted on 2006-11-03
7
241 Views
Last Modified: 2010-04-16
Hi,

im still battleing my user base, many of whom have a mania for leaving machines logged on exposing my databases to all and sundry.

the IT dept have refused to create a new group in their group policy that will logout or lock the users who do this and my boss has refused my request to deny the repeat offenders access to my db's.

time to get tough.

i want to try and program a vb executable or embed vb into my applications (access mde's/ade's with an sql backend) which will detect if there has been no activity for a certain period and then deny them access to any of the apps i decide.

the db is for the school i work at and as part of the DPA we can't have all the contact, pastoral or academic info accesible by anyone and the only way i can stop this it seems is by using code that will detect periods of inactivity and then restrict access to that data.

and before any anyone ask no i can't simply ask the users to lock their machines they don't listen!!!

im waiting for an old question to be refunded so will up the points for this when it does.

cheers

greg

0
Comment
Question by:Dubs
[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
  • 4
  • 3
7 Comments
 
LVL 35

Expert Comment

by:mvidas
ID: 17866207
Hi Greg,

You could use the getqueuestatus API to check for keyboard or mouse movement in the app:

Option Explicit
Private Declare Function GetQueueStatus Lib "user32" (ByVal fuFlags As Long) As Long
Private Const TIMEOUTSECONDS As Long = 3600
Private Const QS_KEY = &H1
Private Const QS_MOUSEMOVE = &H2
Private Const QS_MOUSEBUTTON = &H4
Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
Private Const QS_INPUT = (QS_MOUSE Or QS_KEY)
Private bCancel As Boolean
Private Sub WaitForIdle(ByVal TimeOut_InSec As Long)
 Dim t As Double
 t = Timer
 Do While bCancel = False
  If GetQueueStatus(QS_INPUT) Then
   t = Timer
   DoEvents
  End If
  If Timer - t >= TimeOut_InSec Then Exit Do
 Loop
End Sub
Public Sub StartCheckingIdle()
 Do Until bCancel
  WaitForIdle TIMEOUTSECONDS
  If bCancel = False Then Call AppWentIdle
  Do Until GetQueueStatus(QS_INPUT) Or bCancel
   DoEvents
  Loop
 Loop
End Sub
Public Sub StopCheckingIdle()
 bCancel = True
End Sub
Private Sub AppWentIdle()
 'what to do when it goes idle
End Sub

Matt
0
 

Author Comment

by:Dubs
ID: 17928734
do i run this as a module within my applications?

or ode sthis run as a code ij the backghround of windows?

just trying tow ork out how to deploy the code

greg
0
 
LVL 35

Expert Comment

by:mvidas
ID: 17929638
Hi Greg,

You would use it within your application.  How you want to use it is up to you, but I'll give you a suggestion:

-In Form_Load (or whatever your first procedure is), call StartCheckingIdle.  It will wait for a period of inactivity (TIMEOUTSECONDS constant, currently an hour), and when the app has been idle for that long it will call "AppWentIdle".
-In the AppWentIdle sub, call whatever routine you have to lock out the users.  You will want to put some kind of error checking in there to see if the user has access, as this will be fired every hour the user has been idle.
-In Form_Unload (or whenever you want the code to stop checking for idle users) call StopCheckingIdle to set the boolean cancel variable.

I adapted this code from http://www.freevbcode.com/ShowCode.Asp?ID=3297 and in looking there you can see that I changed it a little bit but the general idea is still there.  That was aimed more at a VB form than a standalone module though, if that helps at all.

Matt
0
Independent Software Vendors: 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!

 

Author Comment

by:Dubs
ID: 17929772
ah i see,

what i need to do is have something run outside of apps (if possible)

the users leave their machines on and i need code that will detect that this has been done (by calculating period of inactivity) and then deny access to all apps i specify..

is the above possible?

0
 
LVL 35

Accepted Solution

by:
mvidas earned 45 total points
ID: 17929831
I've never had a need to do this, but it looks like the code at http://www.freevbcode.com/ShowCode.ASP?ID=3662 should be what you need.  Aside from simply killing the processes of the apps you want to lock out, I don't know how you'd do it from the outside like this (unless you can control them programmatically).
0
 

Author Comment

by:Dubs
ID: 17929951
nice one,

thanks for this

greg
0
 
LVL 35

Expert Comment

by:mvidas
ID: 17929982
Glad to help!
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

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.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

752 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