Hi everyone
I had an interesting problem today with a client.
I have set up security and privilege on a database depending on NT User Login. However, I've only just realised that the code returns the profile name and not the login name. This company has the profile name "USER" generic to its profiles for some strange reason. It may be a group issue, I'm not network savvy.
Does anyone know of a way of retrieving the actual login name.
The code I am using is the standard code as below ...
[code=vb]
Declare Function GetUserName& Lib "advapi32.d ll" Alias "GetUserNam eA" (ByVal lpBuffer As String, nSize As Long)
Function sys_OrigUserID( ) As String
On Error GoTo Err_sys_OrigUse rID
' Returns the username of the current logged in user.
Dim s$, cnt&, dl&
Dim max_String As Integer
Dim usename As String
max_String = 30
cnt& = 199
s$ = String$(max_Str ing, 1)
dl& = GetUserName(s$, cnt)
usename = Trim$(left$(s$, cnt))
usename = UCase(Mid(usena me, 1, Len(usename) - 1))
sys_OrigUserID = usename
Exit_sys_OrigUs erID:
Exit Function
Err_sys_OrigUse rID:
Select Case Err
Case 0 '.insert Errors you wish to ignore here
Resume Next
Case Else '.All other errors will trap
Beep
MsgBox Err.Description , , "Error in Function SystemCode.sys_ OrigUserID"
Resume Exit_sys_OrigUs erID
End Select
Resume 0 '.FOR TROUBLESHOOTING
End Function
[/code]
I had an interesting problem today with a client.
I have set up security and privilege on a database depending on NT User Login. However, I've only just realised that the code returns the profile name and not the login name. This company has the profile name "USER" generic to its profiles for some strange reason. It may be a group issue, I'm not network savvy.
Does anyone know of a way of retrieving the actual login name.
The code I am using is the standard code as below ...
[code=vb]
Declare Function GetUserName& Lib "advapi32.d ll" Alias "GetUserNam eA" (ByVal lpBuffer As String, nSize As Long)
Function sys_OrigUserID( ) As String
On Error GoTo Err_sys_OrigUse rID
' Returns the username of the current logged in user.
Dim s$, cnt&, dl&
Dim max_String As Integer
Dim usename As String
max_String = 30
cnt& = 199
s$ = String$(max_Str ing, 1)
dl& = GetUserName(s$, cnt)
usename = Trim$(left$(s$, cnt))
usename = UCase(Mid(usena me, 1, Len(usename) - 1))
sys_OrigUserID = usename
Exit_sys_OrigUs erID:
Exit Function
Err_sys_OrigUse rID:
Select Case Err
Case 0 '.insert Errors you wish to ignore here
Resume Next
Case Else '.All other errors will trap
Beep
MsgBox Err.Description , , "Error in Function SystemCode.sys_ OrigUserID"
Resume Exit_sys_OrigUs erID
End Select
Resume 0 '.FOR TROUBLESHOOTING
End Function
[/code]
Comment