LDB

Le .LDB est automatiquement créé à l'ouverture de la base de données, et est automatiquement effacé lors de sa fermeture. Ce fichier LDB contient le nom des machines qui se connectent, avec les noms des utilisateurs. D'après ce que j'ai pu constater par moi même, ce fichier LDB ajoute les utilisateurs au fur et à mesure que les utilisateurs se loguent sur la base de données, mais ce .LDB n'enlève pas les utilisateurs au fur et à mesure qu'ils se déconnectent.

Dans un forum Access, j'ai récupéré ce bout de code, que je n'ai pas testé, qui permettrait de savoir (si ça marche) quels sont les utilisateurs connectés simultanément grâce à ce LDB :

' Subject : WhosOn()
' Purpose : Will read *.LDB file and read who's currently
' logged on and their station name.
'
' The LDB file has a 64 byte record.
'
' The station name starts at byte 1 and is null
' terminated.
'
' Log-in names start at the 33rd byte and are
' also null terminated.
'
' I had to change the way the file was accessed
' because the Input() function did not return
' nulls, so there was no way to see where the
' names ended.
'---------------------------------------------------------------------------
----------
Private Function WhosOn() As String
Type UserRec
     FLigne(1 To 64) As String * 1  'taille d'une ligne dans un .ldb
End Type

On Error GoTo Err_WhosOn

Dim iLDBFile As Integer, iStart As Integer
Dim iLOF As Integer, i As Integer
Dim sPath As String, x As String
Dim sLogStr As String, sLogins As String
Dim sMach As String, sUser As String
Dim rUser As UserRec ' Defined in General
Dim dbCurrent As Database

' Get Path of current database. Should substitute this code
' for an attached table path in a multi-user environment.
' Iterate thru dbCurrent.LDB file for login names.

sPath = appGetSetting(appSI_NomApplication, "Init",
"appDernierCheminHote") & _
appGetSetting(appSI_NomApplication, "Init", "appNomHote") & _
".LDB"

' Test for valid file, else Error

x = Dir(sPath)
iStart = 1
iLDBFile = FreeFile

Open sPath For Binary Access Read Shared As iLDBFile
iLOF = LOF(iLDBFile)
Do While Not EOF(iLDBFile)
Get iLDBFile, , rUser
With rUser
i = 1
sMach = ""
While .bMach(i) <> 0
sMach = sMach & Chr(.bMach(i))
i = i + 1
Wend
i = 1
sUser = ""
While .bUser(i) <> 0
sUser = sUser & Chr(.bUser(i))
i = i + 1
Wend
End With
sLogStr = sMach & " -- " & sUser
If InStr(sLogins, sLogStr) = 0 Then
sLogins = sLogins & sLogStr & ";"
End If
iStart = iStart + 64 'increment to next record offset
Loop
Close iLDBFile
WhosOn = sLogins

Set dbCurrent = Nothing

Exit_WhosOn:
Exit Function

Err_WhosOn:
If Err = 68 Then
MsgBox "Couldn't populate the list", 48, "No LDB File"
Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
Close iLDBFile
End If
Resume Exit_WhosOn

End Function