Re: Get domain username

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
.



Relevant Pages

  • Re: Index for username/password
    ... say that users want to be able to define customer ... A username in a login table is a little different. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Get domain username
    ... I am using an Access ADP project which connects to SQL server using an SQL ... login. ... My problem is obtaining a user’s individual domain login to ... I have a table which has a column (UserName) with the Default ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Unexpected Login Screen When Accessing SQL Data Via .NET Intra
    ... >> data and the SQL Server is on the same server. ... >> My problem is that one user has started getting a login popup ... >> right in via Windows Authentication like everyone else and like they ...
    (microsoft.public.sqlserver.connect)
  • Re: cannot acees two databases as owner
    ... it does not matter you are a member of the ... the sysadmin fixed server role or if there is no any other Login which is ... group if it's a domain) and you can login to your SQL Server with, ...
    (microsoft.public.sqlserver.setup)
  • Re: Database security design with ASP.net and form-based authentication
    ... Since you already have forms-based security, why not use a single SQL login ... for all database access? ... data entry, guest/view only, admin, report viewer. ... so I'm using SQL Server authentication. ...
    (microsoft.public.sqlserver.security)