Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2005
    Posts
    31

    Exclamation 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, _
    , "{947bb102-5d43-11d1-bdbf-00c04fb92675}")

    '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
    End If
    rs.MoveNext
    Loop
    List1.RowSource = str
    rs.Close
    Set rs = Nothing
    Set cn = Nothing

  2. #2
    Join Date
    Jan 2005
    Location
    United Arab Emirates
    Posts
    23
    Try changing

    str = "User Name"
    to

    str = Environ("USERNAME")

  3. #3
    Join Date
    Feb 2005
    Posts
    31
    Now it tells me the first and second lines are missing references. Any ideas?

  4. #4
    Join Date
    Jan 2005
    Location
    United Arab Emirates
    Posts
    23
    what version of Access you use?

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    first and second lines are missing references
    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

    BTW....
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •