Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirming User of database without password entry 1

Status
Not open for further replies.

mtnclark

Technical User
Jul 16, 2002
12
GB
Hello,
I am not sure if this is possible but what I am trying to do is to confirm the users identity without them having to enter a password. The access database I am working with is networked and each user has a specific profile i.e. C:\WINDOWS\Profiles\UserId.
Is there a way of comparing the path of the users profile with a String. I had in mind the following.
If ( C:\WINDOWS\Profiles\Marty1= "C:\WINDOWS\Profiles\Marty1")
Then user is Marty.

Any help would be greatly appreciated.
Marty..
 
If you are using NT or Win2000 then environ$("username") will usually return the username of the current user. If this doesn't work on your lan, let me know & I'll dig out some alternate code.


HTH

Ben ----------------------------------------
Ben O'Hara
Home: bpo@SickOfSpam.RobotParade.co.uk
Work: bo104@SickOfSpam.westyorkshire.pnn.police.uk
(in case you've not worked it out get rid of Sick Of Spam to mail me!)
Web: ----------------------------------------
 
There is another solution to return the username of the current user : Create a module

Declare Function WNetGetUser Lib "mpr" Alias "WNetGetUserA" (ByVal lpName As String, ByVal _
lpUserName As String, lpnLength As Long) As Long

Const NoError = 0
Function GetUserName() As String
Const lpnLength As Integer = 255
Dim Status As Integer
Dim lpName, lpUserName As String
lpUserName = Space$(lpnLength + 1)
Status = WNetGetUser(lpName, lpUserName, lpnLength)
If Status = NoError Then
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else
MsgBox "Unable to get the name."
End If
GetUserName = lpUserName

End Function

So, you can return the username in a form, a report, a query
with the source control of a field (=GetUserName)

Regards,

Franck
 
Thanks all,
It worked a treat.. I used ur code Franck, I work under an antiquated win95 env so was glad to see compatibility

--------
Marty..
 
Franck,
Would it be possible if you could explain a little how this code offering works.
Thnx
marty.
 
Hi Marty,

' 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.
MsgBox "Unable to get the name."
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top