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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capturing SQL Server Login ID from Access

Status
Not open for further replies.

Gti

Programmer
Jul 23, 2001
99
PT
Hi all,

I've created an Access 2002 database that has linked tables from MS SQL Server 7.0. Assuming that no security settings were done on the Access mdb file, we know that SQL Server will prompt for the login id and password screen before it allows access to its tables. That is fine with me. The
problem is how do I capture the Login ID of the user so that I can use this value to restrict the user on certain Access objects in the front end.

I welcome any suggestions. Thanks in advance.

Gti ;-)
 
Assuming thery are loggin into an NT domain:

Private Sub TestEnviron()

Dim txtUser As String

txtUser = Environ("username")
MsgBox txtUser


End Sub

or


Public Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = &quot;&quot;
End If
End Function
Tyrone Lumley
augerinn@gte.net
 
Hi, Databaseguy.

Sorry, but you don't understand what i meen. What i need is capture the Login ID of the user from SQL Server. We know that SQL Server will prompt for the login id and password screen before it allows access to its tables, and what i need is the Login Id.

I welcome any suggestions. Thanks in advance.

Gti ;-)
 
If you used trusted connections and did not require passwords the above method would work. May I suggest you post your question in SQL Server forum... All you need to do is run a SQL Passthrough query returning the value of the appropritate functions/statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top