Using the computer login for security

G

Guest

I am working with an access database and I need to set it up for users to only have access to certain areas. I have looked at the security setting built into Access and I know I can use them if I have to. What my question is:

1. I have VB code from an Excel application that will allow me to get the name of the peson on the computer, pulled from the windows login which all of our users have different login names and passwords (we are on a network). The code I have is listed below.

2. Is there a way to set-up Access to use this as the user name and thus nobody would have to type in a password to get in. Whenever you log into the computer and open up Access it would know who you are and thus you would have access rights based on your actuall login.

I am sorry if this is a little confusing, I am struggling to explain exactly what I am wanting. Basically I want to use the User Name in the Windows Log In screen to use as the name for access, then I can assign that name as a usergroup and give them certain rights. But how to I make access except this as the user name instead of making someone type it in.

Thank you for any advise you have have, and if you need me to try and explain this differently please let me know.

Rich Adams


' Declare for call to mpr.dll.
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As Long

Const NOERROR = 0 'The Function call was successful
Sub GetUserNameForLogIn()
' Buffer size for the return string.
Const lpnLength As Integer = 255
' Get return buffer space.
Dim status As Integer
' For getting user information.
Dim lpName, lpUserName As String
' Assign the buffer size constant to lpUserName.
lpUserName = Space$(lpnLength + 1)
' Get the log-on name of the person using product.
status = WNetGetUser(lpName, lpUserName, lpnLength)
' See whether error occurred.
If status = NOERROR Then
' This line removes the null character. Strings in C are null-
' terminated. Strings in Visual Basic are not null-terminated.
' The null character must be removed from the C strings to be used
' cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else
' An error occurred.
On Error Resume Next
End
End If
'Display the name of the person logged on to the machine.
MsgBox "The person logged on this machine is: " & lpUserName
End Sub
 
D

Douglas J. Steele

Sorry, Access doesn't support Trusted Connections like SQL Server does. In
other words, what you want isn't possible.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Rich Adams said:
I am working with an access database and I need to set it up for users to
only have access to certain areas. I have looked at the security setting
built into Access and I know I can use them if I have to. What my question
is:
1. I have VB code from an Excel application that will allow me to get
the name of the peson on the computer, pulled from the windows login which
all of our users have different login names and passwords (we are on a
network). The code I have is listed below.
2. Is there a way to set-up Access to use this as the user name and
thus nobody would have to type in a password to get in. Whenever you log
into the computer and open up Access it would know who you are and thus you
would have access rights based on your actuall login.
I am sorry if this is a little confusing, I am struggling to explain
exactly what I am wanting. Basically I want to use the User Name in the
Windows Log In screen to use as the name for access, then I can assign that
name as a usergroup and give them certain rights. But how to I make access
except this as the user name instead of making someone type it in.
Thank you for any advise you have have, and if you need me to try and
explain this differently please let me know.
 
G

Graham R Seach

Rich,

As John says, this is impossible in native Access, however, if you're
prepared to do some extra coding, you may be able to do something. Here are
two ideas you might try:

1. You can build a table/subtable pair, where the master table lists all the
forms, reports and backend tables in the database. The child table then
contains records describing the permissions each user has to each database
object. You could then write code throughout your application to check the
permissions a user has before they are allowed to access whatever it is
they're trying to access.

This of course is not going to stop anyone gaining direct access to the
tables, but it will offer some measure of control through the user interface
you've defined.

2. Another alternative is implement standard Access user/group-level
security, and write a small VB utility to launch the Access application from
the desktop. This VB utility can retrieve the users' login and launch the
secured Access application via command line.

Other than that, I don't think there are any other alternatives.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Rich Adams said:
I am working with an access database and I need to set it up for users to
only have access to certain areas. I have looked at the security setting
built into Access and I know I can use them if I have to. What my question
is:
1. I have VB code from an Excel application that will allow me to get
the name of the peson on the computer, pulled from the windows login which
all of our users have different login names and passwords (we are on a
network). The code I have is listed below.
2. Is there a way to set-up Access to use this as the user name and
thus nobody would have to type in a password to get in. Whenever you log
into the computer and open up Access it would know who you are and thus you
would have access rights based on your actuall login.
I am sorry if this is a little confusing, I am struggling to explain
exactly what I am wanting. Basically I want to use the User Name in the
Windows Log In screen to use as the name for access, then I can assign that
name as a usergroup and give them certain rights. But how to I make access
except this as the user name instead of making someone type it in.
Thank you for any advise you have have, and if you need me to try and
explain this differently please let me know.
 
G

Graham R Seach

Oops - I meant to say Douglas - Not John. Sorry Doug!

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


Rich Adams said:
I am working with an access database and I need to set it up for users to
only have access to certain areas. I have looked at the security setting
built into Access and I know I can use them if I have to. What my question
is:
1. I have VB code from an Excel application that will allow me to get
the name of the peson on the computer, pulled from the windows login which
all of our users have different login names and passwords (we are on a
network). The code I have is listed below.
2. Is there a way to set-up Access to use this as the user name and
thus nobody would have to type in a password to get in. Whenever you log
into the computer and open up Access it would know who you are and thus you
would have access rights based on your actuall login.
I am sorry if this is a little confusing, I am struggling to explain
exactly what I am wanting. Basically I want to use the User Name in the
Windows Log In screen to use as the name for access, then I can assign that
name as a usergroup and give them certain rights. But how to I make access
except this as the user name instead of making someone type it in.
Thank you for any advise you have have, and if you need me to try and
explain this differently please let me know.
 
G

Guest

Well that is at least a starting point. I will try some things and see what I can come up with. Thanks for your insights

----- Graham R Seach wrote: ----

Oops - I meant to say Douglas - Not John. Sorry Doug

Regards
Graham R Seac
Microsoft Access MV
Sydney, Australi

Microsoft Access 2003 VBA Programmer's Referenc
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.htm


Rich Adams said:
I am working with an access database and I need to set it up for users t
only have access to certain areas. I have looked at the security settin
built into Access and I know I can use them if I have to. What my questio
isthe name of the peson on the computer, pulled from the windows login whic
all of our users have different login names and passwords (we are on
network). The code I have is listed belowthus nobody would have to type in a password to get in. Whenever you lo
into the computer and open up Access it would know who you are and thus yo
would have access rights based on your actuall loginexactly what I am wanting. Basically I want to use the User Name in th
Windows Log In screen to use as the name for access, then I can assign tha
name as a usergroup and give them certain rights. But how to I make acces
except this as the user name instead of making someone type it in
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top