Question Current Users in a list

MOTOWN44

Registered User.
Local time
Today, 04:58
Joined
Aug 18, 2009
Messages
42
Morning all

I know there is a method of producing a list of all the users currently using a database but these always are displayed as “Admin” because it uses the users and groups function within access to get the information.

Is there a way of making it display the users windows log on?

I've been playing on with the following code which populates the information in to a listbox. I can get the computer name to display correctly but not the username because as was expected the username again is always “admin”

Code:
Private Sub GenerateUserList()
 
Const conUsers = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
  
Dim cnn As ADODB.Connection, fld As ADODB.Field, strUser As String
Dim rst As ADODB.Recordset, intUser As Integer, varValue As Variant
  
Set cnn = CurrentProject.Connection
Set rst = cnn.OpenSchema(Schema:=adSchemaProviderSpecific, SchemaID:=conUsers)
  
'Set List Box Heading
strUser = "Computer;UserName;Connected?;Suspect?[B];ID[/B]"
  
With rst    'fills Recordset (rst) with User List data
  Do Until .EOF
    intUser = intUser + 1
      For Each fld In .Fields
        varValue = fld.Value
          'Some of the return values are Null-Terminated Strings, if
          'so strip them off
          If InStr(varValue, vbNullChar) > 0 Then
            varValue = Left(varValue, InStr(varValue, vbNullChar) - 1)
          End If
          strUser = strUser & ";" & varValue
      Next
            [B]strUser = strUser & ";" & ReturnNTName[/B]
        .MoveNext
  Loop
End With
  
Me!txtTotalNumOfUsers = intUser        'Total # of Users
  
'Set up List Box Parameters
Me!lstUsers.ColumnCount = 5
Me!lstUsers.RowSourceType = "Value List"
Me!lstUsers.ColumnHeads = False
  lstUsers.RowSource = strUser       'populate the List Box
  
'Routine cleanup chores
Set fld = Nothing
Set rst = Nothing
Set cnn = Nothing
End Sub


I also have a function called ReturnNTName which grabs the current username (this works if I set a text box to display the ReturnNTName value) and have added the bits in bold to the code to see if this will display the username of the DB user in my list. But all this does is display my username against every user its doesn’t pull through the users username to display it separately to mine.

I hope this is possible as it would certainly make updating and collecting our stats much easier

Thanks in advance
 
You might want to look into LDAP or create a table with Computernames and User login names.

Opening a currentproject connection gives all computers that have opened the current access database (application). In a (n)FE to (1)BE environment you will only get one(!) result. When you use a centralised backend let your variable cnn point to the backend instead of the frontend.

HTH:D
 
Tharks for getting back to me :)

creating a list of computers and user names isnt really a viable option for me as we all work of UTC machines which run a "session" on a server and any 1 server can have 400 people running sessions. we are also a large organisation with around 3000 staff.

if i split it down in to a FE and BE surely i would still end up with everyone been called admin still? the computer name part of my code works fine. granted it just displays the server that a user is connected to but there is a difference in results dpending on the user.

i never thought of using LDAP but tbh even if i had i wouldnt have a clue how to! so a push rather than a nudge in that direction would be appreciated if you think that is the best solution

Thanks
 
Yes, everyone is admin but in a local FE there is only one user. In a BE there are usually more users and more machines.

You can use LDAP to show a users name and store this information in your log table or whatever. It is not possible to see who's in the database using LDAP. Not directly that is.

Here's my LDAP sample. Works only when LDAP is available!

Share & Enjoy!
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom