Solved

VB Code: blcok access to apps after period of inactivity

Posted on 2006-11-03
7
235 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
  • 4
  • 3
7 Comments
 
LVL 35

Expert Comment

by:mvidas
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Dubs
Comment Utility
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
Comment Utility
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
Comment Utility
nice one,

thanks for this

greg
0
 
LVL 35

Expert Comment

by:mvidas
Comment Utility
Glad to help!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to split this in C++ 4 76
Magic Software info 18 100
Counting documents in a Domino View 3 31
move one pixel 4 38
This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

762 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