graviz
Registered User.
- Local time
- Yesterday, 17:04
- Joined
- Aug 4, 2009
- Messages
- 167
I have a table call "User_Auth" with two fields (Name & NT_Login). I have some code where it checks to see what a users nt login is and stores it in a variable.
Code For User Name Checking:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
I've always hard coded it as to which users I want to give access to (i.e. If fOSUserName = "john.smith" Then" something) . I have a project I'm working on where I would like it to loop through that table and see if it matches one of the users. I know it's probably basic but could someone please assist me with some code to get this to work?
User Name Stored in "fOSUserName"
Table Name: User_Auth
NT Field Name: NT_Login
Thanks!
Code For User Name Checking:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
I've always hard coded it as to which users I want to give access to (i.e. If fOSUserName = "john.smith" Then" something) . I have a project I'm working on where I would like it to loop through that table and see if it matches one of the users. I know it's probably basic but could someone please assist me with some code to get this to work?
User Name Stored in "fOSUserName"
Table Name: User_Auth
NT Field Name: NT_Login
Thanks!