Connecting Tech Pros Worldwide Forums | Help | Site Map

Access Security

Newbie
 
Join Date: Oct 2009
Posts: 14
#1: 3 Weeks Ago
hay iam back . so itis shotokan too? weired i dk but here brown belt is 2 and 1 kius blue one is called 3kiu , green, orange 6 and 5 kiu, yellow 6 and 7 . that is the system here and shotokan too, but anyways itis just amartial art, and yap keep ur self strong :)

i have another question for u (told ya u won't get rid of me XD)
this time i don't have adata base or something complicated i just want to ask about the access programme abilities and limits. so i want to know is it possible to creat a user name and password for specific users.

for example , like when i logg in in yahoo account.i sign up then i logg in after my user name and password are saved in yahoo db

in access let's say i have a table with 7 names, and i closed my database so no one can access this data base but i want only those 7 people to access the data base, is this possible in access???

thank you
best answer - posted by NeoPa
It is possible (or was at least - I hear they stopped it in Access 2007), but it is really not a very good system for many reasons, one of which is that you either have a scenario where anyone can quite easily get in as Administrator, or you have to manage the whole thing with the possibility of losing access to the file completely if you lose the System.Mdw file. Not to mention how much of a head-ache it is keeping it up-to-date when you make any amendments.

Personally, where this is a requirement, I tend to get the logged on user's name and check it against the allowed users list (that I store in a table) for each object.

The code I use for this is :
Expand|Select|Wrap|Line Numbers
  1. 'GetUser returns the user's logged on name.
  2. Public Function GetUser() As String
  3.     Dim strUserKey As String
  4.  
  5.     If Environ("OS") = "Windows_NT" Then
  6.         strUserKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
  7.         GetUser = RegRead(conHKLM, strUserKey, "DefaultUserName")
  8.     Else
  9.         'Windows
  10.         strUserKey = "Network\Logon"
  11.         GetUser = RegRead(conHKLM, strUserKey, "username")
  12.     End If
  13. End Function
It uses an OS function from another module which is :
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
  2.     Alias "RegOpenKeyExA" (ByVal hKey As Long, _
  3.                            ByVal lpSubKey As String, _
  4.                            ByVal ulOptions As Long, _
  5.                            ByVal samDesired As Long, _
  6.                            phkResult As Long) As Long
  7. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) _
  8.                              As Long
  9. Private Declare Function RegQueryValueExStr Lib "advapi32.dll" _
  10.     Alias "RegQueryValueExA" (ByVal hKey As Long, _
  11.                               ByVal lpValueName As String, _
  12.                               ByVal lpReserved As Long, _
  13.                               lpType As Long, _
  14.                               ByVal lpData As String, _
  15.                               lpcbData As Long) As Long
  16.  
  17. Public Function RegRead(ByVal lngHive As Long, _
  18.                         ByVal strKey As String, _
  19.                         ByVal strValue As String) As Variant
  20.     Dim intIdx As Integer, intHK As Integer
  21.     Dim strWork As String
  22.     Dim lngRet As Long, cbLen As Long, lngHKey As Long, lngType As Long
  23.  
  24.     RegRead = Null
  25.     strKey = strKey & Chr(0)
  26.     lngRet = RegOpenKeyEx(lngHive, strKey, 0, conKeyRead, lngHKey)
  27.     If lngRet = conOK Then
  28.         'Create buffer to store value
  29.         strWork = Space(255)
  30.         cbLen = 255
  31.         lngRet = RegQueryValueExStr(lngHKey, _
  32.                                     strValue, _
  33.                                     0&, _
  34.                                     lngType, _
  35.                                     strWork, _
  36.                                     cbLen)
  37.         RegRead = Left(strWork, cbLen - 1)
  38.         If Len(RegRead) = 254 Then RegRead = Null
  39.         'Close key
  40.         Call RegCloseKey(lngHKey)
  41.     End If
  42. End Function

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,765
#2: 3 Weeks Ago

re: Access Security


It is possible (or was at least - I hear they stopped it in Access 2007), but it is really not a very good system for many reasons, one of which is that you either have a scenario where anyone can quite easily get in as Administrator, or you have to manage the whole thing with the possibility of losing access to the file completely if you lose the System.Mdw file. Not to mention how much of a head-ache it is keeping it up-to-date when you make any amendments.

Personally, where this is a requirement, I tend to get the logged on user's name and check it against the allowed users list (that I store in a table) for each object.

The code I use for this is :
Expand|Select|Wrap|Line Numbers
  1. 'GetUser returns the user's logged on name.
  2. Public Function GetUser() As String
  3.     Dim strUserKey As String
  4.  
  5.     If Environ("OS") = "Windows_NT" Then
  6.         strUserKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
  7.         GetUser = RegRead(conHKLM, strUserKey, "DefaultUserName")
  8.     Else
  9.         'Windows
  10.         strUserKey = "Network\Logon"
  11.         GetUser = RegRead(conHKLM, strUserKey, "username")
  12.     End If
  13. End Function
It uses an OS function from another module which is :
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
  2.     Alias "RegOpenKeyExA" (ByVal hKey As Long, _
  3.                            ByVal lpSubKey As String, _
  4.                            ByVal ulOptions As Long, _
  5.                            ByVal samDesired As Long, _
  6.                            phkResult As Long) As Long
  7. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) _
  8.                              As Long
  9. Private Declare Function RegQueryValueExStr Lib "advapi32.dll" _
  10.     Alias "RegQueryValueExA" (ByVal hKey As Long, _
  11.                               ByVal lpValueName As String, _
  12.                               ByVal lpReserved As Long, _
  13.                               lpType As Long, _
  14.                               ByVal lpData As String, _
  15.                               lpcbData As Long) As Long
  16.  
  17. Public Function RegRead(ByVal lngHive As Long, _
  18.                         ByVal strKey As String, _
  19.                         ByVal strValue As String) As Variant
  20.     Dim intIdx As Integer, intHK As Integer
  21.     Dim strWork As String
  22.     Dim lngRet As Long, cbLen As Long, lngHKey As Long, lngType As Long
  23.  
  24.     RegRead = Null
  25.     strKey = strKey & Chr(0)
  26.     lngRet = RegOpenKeyEx(lngHive, strKey, 0, conKeyRead, lngHKey)
  27.     If lngRet = conOK Then
  28.         'Create buffer to store value
  29.         strWork = Space(255)
  30.         cbLen = 255
  31.         lngRet = RegQueryValueExStr(lngHKey, _
  32.                                     strValue, _
  33.                                     0&, _
  34.                                     lngType, _
  35.                                     strWork, _
  36.                                     cbLen)
  37.         RegRead = Left(strWork, cbLen - 1)
  38.         If Len(RegRead) = 254 Then RegRead = Null
  39.         'Close key
  40.         Call RegCloseKey(lngHKey)
  41.     End If
  42. End Function
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,765
#3: 3 Weeks Ago

re: Access Security


It's Wado-Ryu, not Shotokan. My mistake.

Kyus from 1 to 9 are :
Brown (3 stripes); Brown (2 stripes); Brown (1 stripe); Blue; Green; Orange; Yellow; Red; White.

I moved your question btw as each question should be in its own thread, though you may post links between threads if it's relevant at all. I will do that here to ensure the conversation makes sense.

This was split from How to structure an access database.
Newbie
 
Join Date: Oct 2009
Posts: 14
#4: 2 Weeks Ago

re: Access Security


yeah itis my mistake srry i should have made anew thread

thanks so much i gave ur answer to my boss and it was a valuable thanx if there is another question i will come to u defenitly :)
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,765
#5: 2 Weeks Ago

re: Access Security


Quote:

Originally Posted by kurai hikari View Post

yeah itis my mistake srry i should have made anew thread

Not a big problem. There are things you need to learn in time but you're still quite new.
Reply