How can I use a users NT login information to open an Access 2003 database with User Level Security?
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. -
Global uName As String
-
-
Private Declare Function GetUserName Lib "advapi32.dll" _
-
Alias "GetUserNameA" (ByVal lpBuffer As String, _
-
nSize As Long) As Long
-
-
Function getUserID() As String
-
Dim len As Long, dlen As Long
-
Dim str As String
-
Dim max_String As Integer
-
Dim username As String
-
-
max_String = 30
-
cnt = 199
-
str = String(max_String, 1)
-
dlen = GetUserName(str, len)
-
username = Trim(Left(str, len))
-
username = UCase(Mid(username, 1, Len(username) - 1))
-
getUserID = username
-
-
End Function
-
In the code behind your startup form, put the following in the forms Load event. -
Private Sub Form_Load()
-
-
uName = getUserID
-
If nz(DLookup("[LoginName]","TableName","[LoginName]='" & uName & "'"), "") = "" Then
-
Application.Quit
-
End If
-
-
End Sub
-
Mary
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. -
Global uName As String
-
-
Private Declare Function GetUserName Lib "advapi32.dll" _
-
Alias "GetUserNameA" (ByVal lpBuffer As String, _
-
nSize As Long) As Long
-
-
Function getUserID() As String
-
Dim len As Long, dlen As Long
-
Dim str As String
-
Dim max_String As Integer
-
Dim username As String
-
-
max_String = 30
-
cnt = 199
-
str = String(max_String, 1)
-
dlen = GetUserName(str, len)
-
username = Trim(Left(str, len))
-
username = UCase(Mid(username, 1, Len(username) - 1))
-
getUserID = username
-
-
End Function
-
In the code behind your startup form, put the following in the forms Load event. -
Private Sub Form_Load()
-
-
uName = getUserID
-
If nz(DLookup("[LoginName]","TableName","[LoginName]='" & uName & "'"), "") = "" Then
-
Application.Quit
-
End If
-
-
End Sub
-
Mary
Thanks Mary!
MMcCarthy 14,534
Recognized Expert Moderator MVP
Thanks Mary!
You're welcome.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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,...
|
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...
|
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...
| |
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...
|
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...
|
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. ...
|
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....
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |