Re: Get domain username
- From: "Mary Chipman [MSFT]" <mchip@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 08 Oct 2009 09:40:49 -0400
If you log on to SQL Server using a SQL login, then SQL Server doesn't
know anything about the Windows domain/credentials of the calling
process. You will need to pass this information from your application
and persist it in SQL Server for that connection.
--Mary
On Thu, 8 Oct 2009 04:17:01 -0700, jez123456
<jez123456@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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
- References:
- Get domain username
- From: jez123456
- Get domain username
- Prev by Date: Get domain username
- Next by Date: Re: ADP Error opening tables on SQL SERVER 2005 and Access 2007
- Previous by thread: Get domain username
- Index(es):
Relevant Pages
|