|
Home > Archive > MS SQL Server > February 2006 > User Account
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi,
I need to know the NT user account of the person who has logged into windows
regardless of its login to SQL Server.
Are there any function in SQL Server?
Thanks in advance,
Leila
| |
| David Portas 2006-02-12, 8:23 pm |
| Leila wrote:
> Hi,
> I need to know the NT user account of the person who has logged into windows
> regardless of its login to SQL Server.
> Are there any function in SQL Server?
> Thanks in advance,
> Leila
Under integrated security use SELECT SYSTEM_USER.
If you login using SQL Server security then I don't think it will be
possible to determine a windows login (if any). Under SQL Server
security the connection might not be associated with a login within any
trusted domain.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
| |
| Louis Davidson 2006-02-12, 8:23 pm |
| I am pretty sure that suser_sname() will give you what you want. You will
want to possibly use original_user() on 2005, in case EXECUTE AS is used.
--
----------------------------------------------------------------------------
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Leila" <Leilas@hotpop.com> wrote in message
news:eY1pd3AMGHA.2916@tk2msftngp13.phx.gbl...
> Hi,
> I need to know the NT user account of the person who has logged into
> windows regardless of its login to SQL Server.
> Are there any function in SQL Server?
> Thanks in advance,
> Leila
>
| |
|
| Hi Louis,
suser_sname() will not work it the user has logged in using SQL
Authetication.
"Louis Davidson" < dr_dontspamme_sql@ho
tmail.com> wrote in message
news:%23AXZGKBMGHA.2604@TK2MSFTNGP09.phx.gbl...
>I am pretty sure that suser_sname() will give you what you want. You will
>want to possibly use original_user() on 2005, in case EXECUTE AS is used.
>
> --
> ----------------------------------------------------------------------------
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
> "Arguments are to be avoided: they are always vulgar and often
> convincing."
> (Oscar Wilde)
>
> "Leila" <Leilas@hotpop.com> wrote in message
> news:eY1pd3AMGHA.2916@tk2msftngp13.phx.gbl...
>
>
| |
| Louis Davidson 2006-02-12, 8:23 pm |
| Yeah sorry, my bad (I didn't really get what you meant by "regardless of its
login" In sysprocesses you might be able to see the hostname, if that is of
any value to you. One trick can be to use the context_info column in
sysprocesses. Look up context_info in books online. You will have to set
the value yourself when you start a connection, but it can be used by a
front end to set a "global" value for later used. It stores a binary value
that can actually be a text value:
Don't know if it will help, but something like this might work:
--
----------------------------------------------------------------------------
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Leila" <Leilas@hotpop.com> wrote in message
news:emHmaQBMGHA.2216@TK2MSFTNGP09.phx.gbl...
> Hi Louis,
> suser_sname() will not work it the user has logged in using SQL
> Authetication.
>
>
>
> "Louis Davidson" < dr_dontspamme_sql@ho
tmail.com> wrote in message
> news:%23AXZGKBMGHA.2604@TK2MSFTNGP09.phx.gbl...
>
>
| |
| Louis Davidson 2006-02-12, 8:23 pm |
| --note, I sometimes hate Outlook Express. I hit ctrl-enter and it sent it
too quick
declare @context_info varbinary(30)
set @context_info = cast('domainname\log
inname' as varbinary(30))
set context_info @context_info
go
select cast(context_info() as varchar(30))
------------------------------
domainname\loginname
--
----------------------------------------------------------------------------
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"Louis Davidson" < dr_dontspamme_sql@ho
tmail.com> wrote in message news:...
> Yeah sorry, my bad (I didn't really get what you meant by "regardless of
> its login" In sysprocesses you might be able to see the hostname, if that
> is of any value to you. One trick can be to use the context_info column
> in sysprocesses. Look up context_info in books online. You will have to
> set the value yourself when you start a connection, but it can be used by
> a front end to set a "global" value for later used. It stores a binary
> value that can actually be a text value:
>
> Don't know if it will help, but something like this might work:
>
>
> --
> ----------------------------------------------------------------------------
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
> "Arguments are to be avoided: they are always vulgar and often
> convincing."
> (Oscar Wilde)
>
> "Leila" <Leilas@hotpop.com> wrote in message
> news:emHmaQBMGHA.2216@TK2MSFTNGP09.phx.gbl...
>
>
|
|
|
|
|