Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracking Machine IDs from Access

Status
Not open for further replies.

tbaguio

Programmer
Sep 25, 2000
41
CA
Hi,

I am currently designing a replicated Access 97 database where using the standard security setup is not an option. I've therefore had to design a custom login for my users.

I wanted to know if there was a way for me to grab the machine ID from where the user opened my replicated Access 97 database. Maybe some built-in function or something?

I know that the .LDB file will display machine IDs (somewhat inaccurately)... but I wanted to grab the ID specifically for each logon. I've seen 3rd party software that does the job nicely, but I need to track the IDs directly from Access. Has anyone done anything like this before?

Thanks,

Theresa "Sleep is the best meditation." - Dalai Lama
 
Hi tbaguio,
I don't know if this will help in your goal, but here is a bit of code which will grab the user's LanID. My guess is, mpr.dll probably has a function for getting the machine name as well, I just don't know the specs of it. But it might be a good place to start:

--- Begin Code ---
Option Compare Database
Option Explicit

Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" _
(ByVal lpName As String, _
ByVal lpUserName As String, lpmLength As Long) _
As Long

Const NoError = 0

Type Member
MemberID As Long
Name As String
Display As Boolean
End Type

Public Function GetVersion()
GetVersion = gstrVersion
End Function

Public Function GetUserLanID()

On Error GoTo Err_GetUserLanID

Const cstLength As Integer = 255
Dim intStatus As Integer
Dim strName, strUser As String

strUser = Space$(cstLength + 1)
intStatus = WNetGetUser(strName, strUser, cstLength)

If (intStatus = NoError) Then
strUser = Left$(strUser, InStr(strUser, Chr(0)) - 1)
Else
MsgBox "Unable to get the name."
End If

GetUserLanID = strUser

Exit_GetUserLanID:
Exit Function

Err_GetUserLanID:
MsgBox Err.Description
Resume Exit_GetUserLanID

End Function
--- End Code ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top