Unanswered: Listbox that displays remote users, currently logged on to database. Can you help?
I was wondering how to display a list of currently logged on users in a listbox. I looked through the forum but could not find what I was looking for. Can you help? No, I'm not looking for the microsoft example that asks you to typer something in the Immediate window.
I've found this code on the net but it doesn't really work... Perhaps something maybe missing???
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str As String
Set cn = CurrentProject.Connection
' The user roster is exposed as a provider-specific schema rowset
' in the 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, _
'Output the list of all users in the current database.
List1.RowSource = ""
str = "User Name"
Do While Not rs.EOF
If rs!connected = True Then
str = str & "," & rs!login_name
List1.RowSource = str
Set rs = Nothing
Set cn = Nothing
the clue is in the error message, you need to make sure you are referencing the ADO library in your project. check the references in the code window
don't use environ() for security related information. the environment variables cannot be trusted to return the true user id.
environment variables can be easily spoofed
eg by typing "Set USERNAME=MyFakeUserID" in a dos command box
environment variables can be easily reset, may depend on a login script, may be discarded by the OS as it gets short on resources. In short don't trust 'em
if you want the userid of the current user then use the API calls designed for that purpose
the currentuser() function returns the userid the person claimed they were on starting the copy access (assuming that you are using workgroup security). So it to is full of holes - you could have the same userid logged in multiple times.
Ideally you need to know the identity of the PC and the user to track down who is using/used a system