2007 Security for 6 users

Singlespeed

Registered User.
Local time
Today, 13:17
Joined
Jun 5, 2009
Messages
33
I want to "secure" my database so that just these 6 users can access it.

Ideally I would use a form of NT authentication to match the userid to a list of user ids in a table.

is there a thread with this already done?
 
With the folowing function you can retrieve the username of the current user.

Code:
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function GetLoginName() As String
    Dim sName As String
    Dim buff As String
    Dim nSize As Long
    
    On Error Resume Next
    
    buff = Space$(MAX_USERNAME)
    nSize = Len(buff)
    
    If GetUserName(buff, nSize) = 1 Then sName = TrimNull(buff)
    
    GetLoginName = sName

End Function
Use the resulting Loginname with the entries in your table and set permissions accordingly.

HTH:D
 
Can you tell me how I use the code to get the loginname to display in a text box on a form or how I can use it in a Query.
 
I've been away for a while. Is your problem solved already?

On a textbox on a form:
Code:
=GetLoginName()
in a query:
Code:
select GetLoginname() as LoginName, * from Table1
or
Code:
Select * from Table where Loginname = GetLoginName()
 

Users who are viewing this thread

Back
Top Bottom