473,513 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MS Access User Level Security with NT

4 New Member
How can I use a users NT login information to open an Access 2003 database with User Level Security?
Apr 24 '07 #1
3 1802
MMcCarthy
14,534 Recognized Expert Moderator MVP
How can I use a users NT login information to open an Access 2003 database with User Level Security?
Create a table to hold the users NT login names. Then add the following declaration and function to a module. Also create a Global variable to hold the user name for further use.
Expand|Select|Wrap|Line Numbers
  1. Global uName As String
  2.  
  3. Private Declare Function GetUserName Lib "advapi32.dll" _
  4.  Alias "GetUserNameA" (ByVal lpBuffer As String, _
  5.  nSize As Long) As Long
  6.  
  7. Function getUserID() As String
  8. Dim len As Long, dlen As Long
  9. Dim str As String
  10. Dim max_String As Integer
  11. Dim username As String
  12.  
  13.     max_String = 30
  14.     cnt = 199
  15.     str = String(max_String, 1)
  16.     dlen = GetUserName(str, len)
  17.     username = Trim(Left(str, len))
  18.     username = UCase(Mid(username, 1, Len(username) - 1))
  19.     getUserID = username
  20.  
  21. End Function
  22.  
In the code behind your startup form, put the following in the forms Load event.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.    uName = getUserID
  4.    If nz(DLookup("[LoginName]","TableName","[LoginName]='" & uName & "'"), "") = "" Then
  5.       Application.Quit
  6.    End If
  7.  
  8. End Sub
  9.  
Mary
Apr 24 '07 #2
ninjasix8
4 New Member
Create a table to hold the users NT login names. Then add the following declaration and function to a module. Also create a Global variable to hold the user name for further use.
Expand|Select|Wrap|Line Numbers
  1. Global uName As String
  2.  
  3. Private Declare Function GetUserName Lib "advapi32.dll" _
  4.  Alias "GetUserNameA" (ByVal lpBuffer As String, _
  5.  nSize As Long) As Long
  6.  
  7. Function getUserID() As String
  8. Dim len As Long, dlen As Long
  9. Dim str As String
  10. Dim max_String As Integer
  11. Dim username As String
  12.  
  13.     max_String = 30
  14.     cnt = 199
  15.     str = String(max_String, 1)
  16.     dlen = GetUserName(str, len)
  17.     username = Trim(Left(str, len))
  18.     username = UCase(Mid(username, 1, Len(username) - 1))
  19.     getUserID = username
  20.  
  21. End Function
  22.  
In the code behind your startup form, put the following in the forms Load event.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.    uName = getUserID
  4.    If nz(DLookup("[LoginName]","TableName","[LoginName]='" & uName & "'"), "") = "" Then
  5.       Application.Quit
  6.    End If
  7.  
  8. End Sub
  9.  
Mary
Thanks Mary!
Apr 25 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Thanks Mary!
You're welcome.
Apr 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
1955
by: Mark Thiel | last post by:
I am working on a project for my company, which has a structure of six major areas. Certain people need to have access to all of the data, whereas other people only require access to the...
0
2079
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
4
7555
by: kthiagar | last post by:
Hi I am trying to connect to a password protected access file from VB.NET. I have no problem in connecting to Access, if I remove the password. This is what I am doing: In the server explorer,...
0
1863
by: accessman2 | last post by:
I have a question. I want to open the MS Access file with user-level Security. I know that if I do NOT setup user-level Security in the MS Access file, and create the table for login in the MS...
8
4393
by: adserte | last post by:
I have a security related question. I was wondering how i can set up security so that for a table: a user can read all data in the table but only update and delete their own data (there is a...
12
1901
by: Dr. Edmund M. Hayes | last post by:
I wrote a access program that works well enough that a handful of people would like to buy it from me. My problem is that if I sell it to someone there is no mechanism that I know of to protect...
22
5768
by: teejayem | last post by:
Hi, I am new to programming with databases and was wanting some help. Is there any way to password protect an access database and access sent sql commands to it via vb.net code? Any help...
5
3005
by: WPW07 | last post by:
Hello, We have several complex applications developed in Access 2003 by various outside consultants. These applications link to a variety of Oracle tables and are used only for Access reports. ...
10
3324
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Not sure if I quite follow that. 1....
2
4021
by: evenlater | last post by:
I realize that user level security is not available for Access databases in the new AK27 format .accdb, and I know that I can still utilize ULS by making my database an .mdb file. But I'm...
0
7264
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7166
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7386
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7543
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7106
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7534
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3236
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.