Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    11

    Unanswered: ID User in Access

    I have an Access 2002 database on the server. I would like to identify the users in the database when the database is open. Does anyone have code that would identify the active users in the database?

    Thanks for your help!!

  2. #2
    Join Date
    Sep 2004
    Location
    Reston, VA
    Posts
    86
    Depending on whether they access the database with a workgroup file (.mdw) or everyone uses that same database directly, you can open a recordset that tells you with this code:

    Const dbSecUserRosterGuid = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
    Dim rst As ADODB.Recordset
    Dim cnn As ADODB.Connection

    Set cnn = New ADODB.Connection
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db_path_and_name;Mode=Share Deny None;" & _
    "Jet OLEDBystem database=systemdb_path_and_name", user_id , password

    Set rst = cnn.OpenSchema(adSchemaProviderSpecific, , dbSecUserRosterGuid)

    The recordset rst will contain the following info:

    COMPUTER_NAME (text)
    LOGIN_NAME (text)
    CONNECTED (boolean)
    SUSPECT_STATE (boolean)

    If the database does not have a workgroup file, then you can probably leave off the System Database, User ID and Password parameters, since you won't need them. In that case, the LOGIN_NAME will be "Admin" for all users and the only way you can distinguish between them is with the COMPUTER_NAME.

  3. #3
    Join Date
    Oct 2004
    Posts
    11
    Thanks for the help, BummerJeff!! I will work on the code this weekend.

Posting Permissions

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