Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get domain username

0 views
Skip to first unread message

jez123456

unread,
Oct 8, 2009, 7:17:01 AM10/8/09
to
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

Mary Chipman [MSFT]

unread,
Oct 8, 2009, 9:40:49 AM10/8/09
to
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

Mehmet

unread,
Nov 27, 2009, 2:20:02 AM11/27/09
to
thanks :)

"jez123456" <jez1...@discussions.microsoft.com>, iletide şunu yazdı
news:A498D8A5-76EE-4290...@microsoft.com...

0 new messages