|
 |
access thread: List users currently using the database
Message #1 by Robeetpotts1@h... on Tue, 27 Aug 2002 14:30:36
|
|
Hi,
I have a secure database, and would like to product a list of those users
who are currently logged on to it. Is this possible.
Rob!
Message #2 by robeetpotts1@h... on Tue, 27 Aug 2002 14:53:08
|
|
> Hi,
> I have a secure database, and would like to product a list of those users
w> ho are currently logged on to it. Is this possible.
> Rob!
I've got this sorted out.
Now what I'd like to know is, is there a way of sending a message to that
users without using e-mail, or phone.
Rob
Message #3 by Beth Moffitt <BethMoffitt@i...> on Tue, 27 Aug 2002 08:53:55 -0500
|
|
I just saw you had the answer before hitting send, but since I prepped this
email, I thought maybe somebody else might benefit from the code.
Create Module with the following code:
Public Sub ShowLogInUsers() 'Jet UserRoster
Dim cn As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim db As Database
Dim rs2 As Recordset
Dim sql As String
Dim strCn As String
Dim str1 As String
Dim str2 As String
On Error GoTo LOGerr
Set db = CodeDb()
strCn = "Data source=" & DBEngine.SystemDB
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open strCn
' user roster is exposed as a provider-specific schema rowset
' in Jet 4 OLE DB provider. You have to use a GUID to
' reference the schema, as provider-specific schemas are not
' listed in ADO's type library for schema rowsets
Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, JET_SCHEMA_USERROSTER)
sql = "select * from tblLogin where 1 = 2"
Set rs2 = db.OpenRecordset(sql)
While Not rs.EOF
str1 = rs.Fields(0)
str2 = rs.Fields(1)
str3 = RS.Fields(2)
str4 = RS.Fields(3)
rs2.AddNew
rs2!COMPUTER_NAME = str1
rs2!LOGIN_NAME = str2
rs2!CONNECTED = str3
rs2!SUSPECT_STATE = str4
rs2.Update
rs.MoveNext
Wend
rs.Close
rs2.Close
cn.Close
Set rs = Nothing
Set rs2 = Nothing
Set cn = Nothing
LOGerr:
MsgBox "Error " & Err & Error$, , "Your Application"
End Sub
Create tblLogin for the fields COMPUTER_NAME, LOGIN_NAME, CONNECTED,
SUSPECT_STATE.
Create report which calls ShowLogInUsers when activated.
On report close, add:
Private Sub Report_Close()
Dim db As Database
Dim sqlDelete As String
On Error Resume Next
Set db = CodeDb()
sqlDelete = "Delete * From tblLogIn"
db.Execute (sqlDelete)
db.Close
Set db = Nothing
End Sub
Regards,
Beth Moffitt
Developer
INI, Inc.
xxx.xxx.xxxx x110
www.iniinc.com
-----Original Message-----
From: Robeetpotts1@h... [mailto:Robeetpotts1@h...]
Sent: Tuesday, August 27, 2002 9:31 AM
To: Access
Subject: [access] List users currently using the database
Hi,
I have a secure database, and would like to product a list of those users
who are currently logged on to it. Is this possible.
Rob!
Message #4 by "Derrick Flores" <Derrick_Flores@s...> on Tue, 27 Aug 2002 08:58:17 -0500
|
|
Rob,
What I do to track users, usage, OS type, and other things that I need
to maintain my databases is that I have a Class Module that pulls
information off the computer that the users is using. Here's my code that
you can copy into a Class. Name the Class "MyComputer".
Option Compare Database
Public myUser As String
Option Explicit
'*************************************************************************
'* INTERFACE *
'*************************************************************************
'Public collections
Public Drives As New Collection
'*************************************************************************
'* IMPLEMENTATION *
'*************************************************************************
'Windows structure declarations
Private Type SYSTEM_INFO
dwOemID As Long
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOrfProcessors As Long
dwProcessorType As Long
dwAllocationGranularity As Long
wProcessorLevel As Integer
wProcessorRevision As Integer
End Type
Private Type OSVERSION_INFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
'Windows API function declarations
Private Declare Function SwapMouseButton Lib "User32" (ByVal bSwap As
Long) As Long
Private Declare Function GetSystemMetrics Lib "User32" (ByVal nIndex As
Long) As Long
Private Declare Sub GetSystemInfo Lib "kernel32" (lpSystemInfo As
SYSTEM_INFO)
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA"
_
(lpVersionInformation As OSVERSION_INFO) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerN
ameA" _
(ByVal sBuffer As String, lSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32" Alias "GetUserNameA" _
(ByVal sBuffer As String, lSize As Long) As Long
Private Declare Function timeGetTime Lib "winmm" () As Long
Private Declare Function GetDesktopWindow Lib "User32" () As Long
Private Declare Function GetWindowRect Lib "User32" (ByVal hwnd As Long,
rectangle As RECT) As Long
Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias
"GetLogicalDriveStringsA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
'Windows constant declarations
Private Const SM_SWAPBUTTON =3D 23
Private Const PROCESSOR_INTEL_386 =3D 386
Private Const PROCESSOR_INTEL_486 =3D 486
Private Const PROCESSOR_INTEL_PENTIUM =3D 586
Private Const PROCESSOR_MIPS_R4000 =3D 4000
Private Const PROCESSOR_ALPHA_21064 =3D 21064
Private Const PROCESSOR_ARCHITECTURE_INTEL =3D 0
Private Const PROCESSOR_ARCHITECTURE_MIPS =3D 1
Private Const PROCESSOR_ARCHITECTURE_ALPHA =3D 2
Private Const PROCESSOR_ARCHITECTURE_PPC =3D 3
Private Const PROCESSOR_ARCHITECTURE_UNKNOWN =3D &HFFFF
Private Const VER_PLATFORM_WIN32s =3D 0
Private Const VER_PLATFORM_WIN32_WINDOWS =3D 1
Private Const VER_PLATFORM_WIN32_NT =3D 2
'Private variable declarations
Private strAccessDir As String
Private strComputerName As String
Private strUserName As String
Private typSysInfo As SYSTEM_INFO
Private typOSVersion As OSVERSION_INFO
Private lngMemoryInstalled As Long
Private lngID As Long
Private Sub Class_Initialize()
'**************************************************************************
***
'* NAME: CLASS_INITIALIZE
'* PURPOSE: To initialize variables when MyComputer object is instantiated
'* ACCEPTS: Nothing
'* RETURNS: Nothing
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES: This procedure also populates the Disks collection
'**************************************************************************
***
Dim strDriveString As String
Dim intDriveLength As Integer
Dim strDrive() As String
Dim intDriveCount As Integer
Dim intPos As Integer
Dim intCounter As Integer
Dim lngBuffSize As Long
'Dim typDrive As Drive
'Get OS version information
typOSVersion.dwOSVersionInfoSize =3D Len(typOSVersion)
GetVersionEx typOSVersion
'Get system information (e.g. processor type)
GetSystemInfo typSysInfo
'Get Access directory
strAccessDir =3D SysCmd(acSysCmdAccessDir)
'Get computer name
strComputerName =3D Space$(255)
lngBuffSize =3D Len(strComputerName)
If GetComputerName(strComputerName, lngBuffSize) Then
strComputerName =3D Left$(strComputerName, lngBuffSize)
End If
'Get user name
strUserName =3D Space$(255)
lngBuffSize =3D Len(strUserName)
If GetUserName(strUserName, lngBuffSize) Then
strUserName =3D Left$(strUserName, lngBuffSize - 1)
myUser =3D strUserName
End If
End Sub
Public Property Get AccessDir() As String
'**************************************************************************
***
'* NAME: ACCESSDIR
'* PURPOSE: To allow the AccessDir property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the directory in which Access is installed
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES:
'**************************************************************************
***
AccessDir =3D strAccessDir
End Property
Public Property Get ButtonsSwapped() As Boolean
'**************************************************************************
***
'* NAME: BUTTONSSWAPPED
'* PURPOSE: To allow the ButtonsSwapped property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: False if the mouse is configured for left-handed use
'* True (non-zero) otherwise
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES:
'**************************************************************************
***
ButtonsSwapped =3D GetSystemMetrics(SM_SWAPBUTTON)
End Property
Public Property Let ButtonsSwapped(bSwap As Boolean)
'**************************************************************************
***
'* NAME: BUTTONSSWAPPED
'* PURPOSE: To allow the ButtonsSwapped property to be set
'* ACCEPTS: True (non-zero) if the mouse is to be configured for left-hande
d use
' False if the mouse is to be configured for (default) right-hand
ed use
'* RETURNS: Nothing
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES:
'**************************************************************************
***
Dim lngSwap As Long
lngSwap =3D CLng(bSwap)
Call SwapMouseButton(lngSwap)
End Property
Public Sub SwapButtons(bSwap As Boolean)
'**************************************************************************
***
'* NAME: SWAPBUTTONS
'* PURPOSE: To expose the SwapButtons method
'* ACCEPTS: True (non-zero) if the mouse is to be configured for left-hande
d use
' False if the mouse is to be configured for (default) right-hand
ed use
'* RETURNS: Nothing
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES: This provides identical functionality to the ButtonsSwapped
property
'**************************************************************************
***
SwapMouseButton bSwap
End Sub
Public Function SwapButtonCheck(bSwap As Boolean) As Boolean
'**************************************************************************
***
'* NAME: SWAPBUTTONCHECK
'* PURPOSE: To allow the ButtonsSwapped property to be set and determine
whether
'* this results in a changed mouse configuration
'* ACCEPTS: True (non-zero) if the mouse is to be configured for left-hande
d use
' False if the mouse is to be configured for (default) right-hand
ed use
'* RETURNS: True if the mouse configuration changes as a result of this
call;
'* False otherwise
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES:
'**************************************************************************
***
Dim bNewState As Boolean
bNewState =3D SwapMouseButton(bSwap)
If bNewState =3D bSwap Then
SwapButtonCheck =3D False
Else
SwapButtonCheck =3D True
End If
End Function
Public Property Get CPUArchitecture() As String
'**************************************************************************
***
'* NAME: CPUARCHITECTURE
'* PURPOSE: To allow the CPUArchitecture property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the type of processor installed
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES: FOr Win95, this will always be "Intel"
'**************************************************************************
***
Select Case typSysInfo.dwOemID
Case PROCESSOR_ARCHITECTURE_INTEL
CPUArchitecture =3D "Intel"
Case PROCESSOR_ARCHITECTURE_MIPS
CPUArchitecture =3D "MIPS"
Case PROCESSOR_ARCHITECTURE_ALPHA
CPUArchitecture =3D "Alpha"
Case PROCESSOR_ARCHITECTURE_PPC
CPUArchitecture =3D "PowerPC"
Case PROCESSOR_ARCHITECTURE_UNKNOWN
CPUArchitecture =3D "Unknown"
End Select
End Property
Public Property Get OSName() As String
'**************************************************************************
***
'* NAME: OSNAME
'* PURPOSE: To allow the OSName property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the name of the operating system installed
'* e.g. Windows NT 4.0 Build 1381
'* ~~~~~~~~~~
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES: Further information is in the OSVersion and OSBuild properties
'**************************************************************************
***
Select Case typOSVersion.dwPlatformId
Case VER_PLATFORM_WIN32_WINDOWS
OSName =3D "Windows 95"
Case VER_PLATFORM_WIN32_NT
OSName =3D "Windows NT"
End Select
End Property
Public Property Get OSVersion() As String
'**************************************************************************
***
'* NAME: OSVERSION
'* PURPOSE: To allow the OSVersion property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the version of the operating system
installed
'* e.g. Windows NT 4.0 Build 1381
'* ~~~
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES: Further information is in the OSVersion and OSBuild properties
'**************************************************************************
***
OSVersion =3D typOSVersion.dwMajorVersion & "." & typOSVersion.dwMinorVersi
on
End Property
Public Property Get OSBuild() As String
'**************************************************************************
***
'* NAME: OSBUILD
'* PURPOSE: To allow the OSBuild property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the build of the operating system
installed
'* e.g. Windows NT 4.0 Build 1381
'* ~~~~
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES: Further information is in the OSVersion and OSBuild properties
'**************************************************************************
***
OSBuild =3D typOSVersion.dwBuildNumber And &HFFFF&
End Property
Public Property Get CPULevel() As String
'**************************************************************************
***
'* NAME: CPULEVEL
'* PURPOSE: To allow the CPULevel property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the level of CPU installed
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES: If the operating system is Win95, this value is found in the
' dwProcessorType element returned by GetSystemInfo. If WinNT,
' the value is in the wProcessorLevel element, and values
returned
' are dependent on processor architecture
'**************************************************************************
***
Select Case typOSVersion.dwPlatformId
Case VER_PLATFORM_WIN32_WINDOWS
Select Case typSysInfo.dwProcessorType
Case PROCESSOR_INTEL_386
CPULevel =3D "386"
Case PROCESSOR_INTEL_486
CPULevel =3D "486"
Case PROCESSOR_INTEL_PENTIUM
CPULevel =3D "Pentium"
End Select
Case VER_PLATFORM_WIN32_NT
Select Case typSysInfo.dwOemID
Case PROCESSOR_ARCHITECTURE_INTEL
Select Case typSysInfo.wProcessorLevel
Case 3
CPULevel =3D "386"
Case 4
CPULevel =3D "486"
Case 5
CPULevel =3D "Pentium"
End Select
Case PROCESSOR_ARCHITECTURE_MIPS
Select Case typSysInfo.wProcessorLevel
Case 4
CPULevel =3D "R4000"
End Select
Case PROCESSOR_ARCHITECTURE_ALPHA
Select Case typSysInfo.wProcessorLevel
Case 21064
CPULevel =3D "21064"
Case 21066
CPULevel =3D "21066"
Case 21164
CPULevel =3D "21164"
End Select
Case PROCESSOR_ARCHITECTURE_PPC
Select Case typSysInfo.wProcessorLevel
Case 1
CPULevel =3D "601"
Case 3
CPULevel =3D "603"
Case 4
CPULevel =3D "604"
Case 6
CPULevel =3D "603+"
Case 9
CPULevel =3D "604+"
Case 20
CPULevel =3D "620"
End Select
Case PROCESSOR_ARCHITECTURE_UNKNOWN
CPULevel =3D "Unknown"
End Select
End Select
End Property
Public Property Get ComputerName() As String
'**************************************************************************
***
'* NAME: COMPUTERNAME
'* PURPOSE: To allow the ComputerName property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the name of the computer
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES:
'**************************************************************************
***
ComputerName =3D strComputerName
End Property
Public Property Get UserName() As String
'**************************************************************************
***
'* NAME: USERNAME
'* PURPOSE: To allow the UserName property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the name of the currently logged-on user
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES:
'**************************************************************************
***
UserName =3D strUserName
End Property
Public Property Get WinStarted() As Date
'**************************************************************************
***
'* NAME: WINSTARTED
'* PURPOSE: To allow the WinStarted property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A date indicating when Windows was last started
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES: This value will not be accurate once the threshold of
timeGetTime
' has been exceeded (around 47 days)
'**************************************************************************
***
WinStarted =3D DateAdd("s", timeGetTime() / -1000, Now)
End Property
Public Property Get ScreenResolution() As String
'**************************************************************************
***
'* NAME: SCREENRESOLUTION
'* PURPOSE: To allow the ScreenResolution property to be inspected
'* ACCEPTS: Nothing
'* RETURNS: A string indicating the current screen resolution (e.g.
640x480)
'* AUTHOR: Rob Smith
'* DATE: 22/06/97
'* NOTES:
'**************************************************************************
***
Dim rct As RECT
Dim hwnd As Long
Dim lngReturn As Long
hwnd =3D GetDesktopWindow()
lngReturn =3D GetWindowRect(hwnd, rct)
ScreenResolution =3D (rct.x2 - rct.x1) & "x" & (rct.y2 - rct.y1)
End Property
Public Property Get ID() As Long
'**************************************************************************
***
'* NAME: ID
'* PURPOSE: To return the unique ID of this class instance
'* ACCEPTS: Nothing
'* RETURNS: A long representing a unique(-ish?) ID
'* AUTHOR: David Sussman
'* DATE: 22/06/97
'* NOTES:
'**************************************************************************
***
ID =3D lngID
End Property
'End of Code
Here's also sample code on how to reference the class module.
Dim strUser As String
strUser =3D MyComputer.UserName
Dim myDB As DAO.Database, rs As DAO.Recordset
Set myDB =3D DBEngine(0).OpenDatabase("C:\WINDOWS\Desktop\Database.mdb",
True)
Set rs =3D myDB.OpenRecordset("UserLogs")
With rs
.AddNew 'Assign values to fields by field name in table
.Fields("UserName") =3D strUser
.Fields("Date") =3D Now()
.Update
.Close
End With
myDB.Close
Good luck,
Derrick Flores
Sony Semiconductor
San Antonio, TX
>>> robeetpotts1@h... 08/27/02 02:53PM >>>
> Hi,
> I have a secure database, and would like to product a list of those
users
w> ho are currently logged on to it. Is this possible.
> Rob!
I've got this sorted out.
Now what I'd like to know is, is there a way of sending a message to that
users without using e-mail, or phone.
Rob
Message #5 by "Foote, Chris" <Chris.Foote@u...> on Tue, 27 Aug 2002 15:00:03 +0100
|
|
Hello Rob.
If you are using NT4 you can use Net Send.
This is lifted from the help file:
---------------
Net Send
Sends messages to other users, computers, or messaging names on the network.
The Messenger service must be running to receive messages.
net send {name | * | /domain[:name] | /users} message
Parameters
name
Is the username, computername, or messaging name to send the message to. If
the name is a computername that contains blank characters, enclose the alias
in quotation marks (" ").
*
Sends the message to all the names in your group.
/domain[:name]
Sends the message to all the names in the computer's domain. If name is
specified, the message is sent to all the names in the specified domain or
workgroup.
/users
Sends the message to all users connected to the server.
message
Is text to be sent as a message.
--------------------
HTH - Spike
> -----Original Message-----
> From: robeetpotts1@h... [mailto:robeetpotts1@h...]
> Sent: Tuesday, August 27, 2002 3:53 PM
> To: Access
> Subject: [access] Re: List users currently using the database
>
>
> > Hi,
>
> > I have a secure database, and would like to product a list
> of those users
> w> ho are currently logged on to it. Is this possible.
>
> > Rob!
>
> I've got this sorted out.
>
> Now what I'd like to know is, is there a way of sending a
> message to that
> users without using e-mail, or phone.
>
> Rob
>
Message #6 by "Carnley, Dave" <dcarnley@a...> on Tue, 27 Aug 2002 09:53:18 -0500
|
|
you could build a timer event into your application that polled a shared
table for messages directed to that particular user or workstation, and if
one is found, displays it. Then as sys admin you need only put a row into
the shared table directed to whoever needs to see the message and the next
time that user's session polls the table it finds the message. You can
build 1000 bells and whistles into this...
-----Original Message-----
From: robeetpotts1@h... [mailto:robeetpotts1@h...]
Sent: Tuesday, August 27, 2002 9:53 AM
To: Access
Subject: [access] Re: List users currently using the database
> Hi,
> I have a secure database, and would like to product a list of those users
w> ho are currently logged on to it. Is this possible.
> Rob!
I've got this sorted out.
Now what I'd like to know is, is there a way of sending a message to that
users without using e-mail, or phone.
Rob
Message #7 by "Haslett, Andrew" <andrew.haslett@i...> on Wed, 28 Aug 2002 06:57:38 +0930
|
|
There's a custom app that does this at www.fmsinc.com . Its free and
displays the currently logged in users and allows you to send messages using
the process as described by Dave. Its basically an upgrade of the old LDB
Viewer from Microsoft.
However after a quick look on their site I can find the download link. If
anyone wants it, let me know and I will send it to them.
Cheers,
Andrew
-----Original Message-----
From: Carnley, Dave [mailto:dcarnley@a...]
Sent: Wednesday, 28 August 2002 12:23 AM
To: Access
Subject: [access] Re: List users currently using the database
you could build a timer event into your application that polled a shared
table for messages directed to that particular user or workstation, and if
one is found, displays it. Then as sys admin you need only put a row into
the shared table directed to whoever needs to see the message and the next
time that user's session polls the table it finds the message. You can
build 1000 bells and whistles into this...
-----Original Message-----
From: robeetpotts1@h... [mailto:robeetpotts1@h...]
Sent: Tuesday, August 27, 2002 9:53 AM
To: Access
Subject: [access] Re: List users currently using the database
> Hi,
> I have a secure database, and would like to product a list of those users
w> ho are currently logged on to it. Is this possible.
> Rob!
I've got this sorted out.
Now what I'd like to know is, is there a way of sending a message to that
users without using e-mail, or phone.
Rob
Message #8 by "Steven White" <Steve.White@m...> on Wed, 28 Aug 2002 02:01:17
|
|
Andrew - could I get you to send me that app (or upload it somewhere), it sounds pretty cool -
If it's better than LDB viewer I can only hope that it's good (Since I know that ldbviewer is not)
By the way, does anyone know if ldbview.hlp actually exists? the LDBViewer file points to it -
but I can't find it anywhere!
Steven.
Steve.White@m...
Message #9 by "Haslett, Andrew" <andrew.haslett@i...> on Wed, 28 Aug 2002 11:47:07 +0930
|
|
Bingo!
Found the link in an old post:
http://www.fmsinc.com/free/utilities/jet4admin.htm
Cheers,
Andrew
-----Original Message-----
From: Steven White [mailto:Steve.White@m...]
Sent: Wednesday, 28 August 2002 11:31 AM
To: Access
Subject: [access] Re: List users currently using the database
Andrew - could I get you to send me that app (or upload it somewhere), it
sounds pretty cool -
If it's better than LDB viewer I can only hope that it's good (Since I know
that ldbviewer is not)
By the way, does anyone know if ldbview.hlp actually exists? the LDBViewer
file points to it -
but I can't find it anywhere!
Steven.
Steve.White@m...
|
|
 |