Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$64,000 Question(s) 1

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US
I'm using VB5 and Acess '97 databases via native Jet. The User Id's at log on provide a unique identifier when users launch the secured app with their password. These ID's are stored in a table as well.

1) Is there a way to determine who gets a minimize button on their application and who does not (AT RUNTIME) without distributing 2 seperate compiled apps?

2) How would you automatically log users off after 15 minutes on inactivity on the system? Which events would you use to do it reliably?

Thanx :)

[sig][/sig]
 
Well i'm thinking depending on which ID logged in you could use the MinButton property for the form and set it to false.

The shutdown one...need to give it some more thought.

Delton.
dphilips@gleanerjm.com [sig][/sig]
 
For starters, you need to 'define' inactivity. Does it mean:

[tab]Changing the current Form
[tab]shifting the focus from/to any object(s)
[tab]Changing the content of some/any field
[tab]any keypress

or what ever you mean.

After you know your definition, the appropiate events are ... easy?/obvious?

Once past the above, you could add a table (fields?) which include the logon Id, LastActivityTime and (perhaps) the user's Group.

Add a timer. If the delta between LastActivityTime and NOW is greater than the threshold (for the User/Group). Cut him loose. [sig]<p>MichaelRed<br><a href=mailto:mred@duvallgroup.com>mred@duvallgroup.com</a><br>There is never time to do it right but there is always time to do it over[/sig]
 
Oh, by the way,

all donations gratefully accepted.

[sig]<p>MichaelRed<br><a href=mailto:mred@duvallgroup.com>mred@duvallgroup.com</a><br>There is never time to do it right but there is always time to do it over[/sig]
 
The problem is a little more complicated than MichaelRed thinks. Saving a log in time doesn't cut it. I need to know when the user has stopped using the app and its sitting idle on the desktop. This means keypresses, mousemoves, and focus events on this form as well as activity on any additional forms that are opened &quot;modal&quot; to the main form. Also, isn't the timer limited to about 60 seconds?

I'm not going to push code into thousands of events- these are busy forms. I need to know if the Access connection can be monitored for activity and how to &quot;disconnect&quot; any users who have been identified as inactive for say 15 minutes.

dellyjim - the Min Button can NOT be set at runtime- only design time. [sig][/sig]
 
Addressing your item #1. I assign members to security groups then when I want to know whether a button should be .enabled = True I check to determine whether they are members of the group that should be using the button. Disregard error handling code as it is unique to our application.

Sample:

If UserIsMemberOfGroup(CurrentUser, &quot;Admins&quot;) Then
btnAdmins.Enabled = True
Else
btnAdmins.Enabled = False
End If

Public Function UserIsMemberOfGroup(strUsr As String, strGrp As String) As Boolean


' This function determines the groups the current user is assigned
' and returns true if the user is a member of the group being
' tested by the parameter strGrp
' Parameters:
' strUsr is a string value for the user to test
' strGrp is a string value for a valid group

Dim wsp As Workspace
Dim dbs As Database
Dim usr As User
Dim grp As Group
Dim strGrps As String

On Error GoTo HandleErr

' Return reference to default workspace.
Set wsp = DBEngine.Workspaces(0)
' Return reference to current database.
Set dbs = CurrentDb
' Set User object to the CurrentUser
Set usr = wsp.Users(strUsr)

For Each grp In usr.Groups
If grp.Name = strGrp Then
UserIsMemberOfGroup = True
GoTo Proc_Exit
End If
DocSkip:
Next grp

Proc_Exit:
Set wsp = Nothing
Set dbs = Nothing
Set usr = Nothing
Set grp = Nothing
Exit Function

HandleErr:
Select Case Err.Number
Case 3033 ' No Permissions
mstrErrors = mstrErrors &amp; PadErrNumber(Err.Number) &amp; &quot;,&quot; &amp; Err.Description &amp; &quot;;&quot;
GoTo DocSkip
Case Else
Call HandleTheError(&quot;basPermissions&quot;, &quot;UserIsMemberOfGroup&quot;, Err, ShowMsg)
End Select
Resume Proc_Exit
Resume

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top