good afternoon all,
i have a DB which i want to be able to use the network name of the user to check to see if they are allowed access to the DB. I am currently using the network name for audit purposes but i am strugglnig to get the netwrok name to check the users table in the DB to see if they are allowed access. i have attached the code i think i need to use but this is not appearing to be working. can someone please assist me in my hour of need of what i need to do and where i need to put things.
Code:
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Static strOSName As String
If Len(strOSName) > 0 Then
FOSUserName = strOSName
Exit Function
End If
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
strOSName = Left$(strUserName, lngLen - 1)
Else
strOSName = vbNullString
End If
FOSUserName = strOSName
End Function
usernm = FOSUserName()
If DCount("Username", "L_Users", "Username='" & usernm & "'") > 0 Then
'carry on
Else
MsgBox "Invalid Username-" & usernm & "- application will close."
Application.Quit
End If