Home > Archive > MS SQL Server > August 2005 > Windows Login Name in TSQL









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]

 

Author Windows Login Name in TSQL
asawyer@chambersREMOVEbelt.com

2005-08-30, 8:23 pm

I've looked but I can't find.
Is there a way to get the windows login name in TSQL?
Also I would like the workstation name (computer name).

The software we use doesn't use a separate login name for each user, so
everyone is actually logging in using the same database login, but I need
some way to get to their computer name and login name.

Thanks,
Alan Sawyer
asawyer@chambersREMOVEbelt.com

2005-08-30, 8:23 pm

I am using SS2k.
Alan Sawyer
Alejandro Mesa

2005-08-30, 8:23 pm

If the authentication being used is "windows authentication", then you can
get it with suser_sname(). If the authentication being used is "sql server"
then you can not see the nt user.

For the "computer name" see host_name in BOL.


AMB

" asawyer@chambersREMO
VEbelt.com" wrote:

> I've looked but I can't find.
> Is there a way to get the windows login name in TSQL?
> Also I would like the workstation name (computer name).
>
> The software we use doesn't use a separate login name for each user, so
> everyone is actually logging in using the same database login, but I need
> some way to get to their computer name and login name.
>
> Thanks,
> Alan Sawyer
>

Narayana Vyas Kondreddi

2005-08-30, 8:23 pm

See SUSER_SNAME function in SQL Server Books Online. Also the HOST_NAME
function.

--
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @ http://vyaskn.tripod.com/


< asawyer@chambersREMO
VEbelt.com> wrote in message
news:uEPF0UZrFHA.3392@TK2MSFTNGP11.phx.gbl...
> I've looked but I can't find.
> Is there a way to get the windows login name in TSQL?
> Also I would like the workstation name (computer name).
>
> The software we use doesn't use a separate login name for each user, so
> everyone is actually logging in using the same database login, but I need
> some way to get to their computer name and login name.
>
> Thanks,
> Alan Sawyer



asawyer@chambersREMOVEbelt.com

2005-08-30, 8:23 pm

Since there is only one user setup in the database, it would have to be
using sql server authentication, wouldn't it??
The individual users are not being setup in the database.
Does this mean there is no way to get it?
Alan Sawyer
Alejandro Mesa

2005-08-30, 8:23 pm

Depend. If the user is bound to a login that is a ntgroup, then you can. You
can see the login using sp_helpuser and inquire master.dbo.syslogins to see
if the login is an ntgroup or ntuser.


AMB



" asawyer@chambersREMO
VEbelt.com" wrote:

> Since there is only one user setup in the database, it would have to be
> using sql server authentication, wouldn't it??
> The individual users are not being setup in the database.
> Does this mean there is no way to get it?
> Alan Sawyer
>

asawyer@chambersREMOVEbelt.com

2005-08-30, 8:23 pm

Doesn't look like that will work
I have 30 users in the software, but a
select * from master.dbo.syslogins only shows 12 records returned.
Alan
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com