Get domain username
- From: jez123456 <jez123456@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 8 Oct 2009 04:17:01 -0700
I am using an Access ADP project which connects to SQL server using an SQL
login (GenLogin). My problem is obtaining a user’s individual domain login to
enter into an audit table.
Internally I can obtain the username using the following function
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 = vbNullString
End If
End Function
This is fine for certain parts of my application; however, it is in the
audit trail where I have problems.
I have a table (AuditLog) which has a column (UserName) with the Default
Value set to suser_sname()
This works ok, but of course will always save the SQL Server login
(GenLogin) and not the individual username.
How can I set the UserName Default Value to use a function that is in the
vba code?
Is there a sql server user defined function that will return this?
Thanks for your help
.
- Follow-Ups:
- Re: Get domain username
- From: Mary Chipman [MSFT]
- Re: Get domain username
- Prev by Date: Re: ADP Error opening tables on SQL SERVER 2005 and Access 2007
- Next by Date: Re: Get domain username
- Previous by thread: Format money vs decimal
- Next by thread: Re: Get domain username
- Index(es):
Relevant Pages
|