Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get nt user name in sql server

Status
Not open for further replies.

baselbj

Programmer
Apr 17, 2002
18
JO
i have a system that use sql server authentication to logon and i need to get the NT user name for that user . a note that you must know that all the user logon with the same name so i need to make a tigger to log all transaction with the NT user name .
 
I don't think you can do it....if I understand you...


Your users are using NT workstations to connect to the SQL server. They login to the NT using their individual login and password, but when they connect to the SQL Server they all use the same login and password. I would think that since the users NT login is never 'passed' to the SQL Server, you can't get that information from the SQL Server, it only exists on the NT workstation.

But, I might be wrong and we'll both learn something new.

-SQLBill
 
Hi,

Can you explain your problem with more detail. Since it is not very clear.

If users uses different NT username but same sql logins e.g. sa
In this case there is no way to differenciate btn the users because NT username will not be considered.

You have to use windows authentication or other way is to create different users in sql-server.
 
thank u all i think its as u say it will never be happen that way thank u again for help

basel
 
Basel,

Is there any special reason you have your users connect to SQL Server using a common login/password?

Even if you don't want to have them all use separate SQL Server logins/passwords, I would think you could have them use their NT login/password to access the SQL Server. Just set it up as a trusted domain.

It's much better security than everyone using the same login/password.

-SQLBill
 
Hai i get that u need to know hoist names
connected to sql server for a process

there is a table sysprocesses in master db
u can use the following query to retrive the hostnames

select distinct hostname from master..sysprocesses

Pl get back if this works down
 
You can also get the host name with the HOST_NAME() function. The following returns the workstation name for the current user.

Select @host=HOST_NAME() Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
thank u all again i think this will help me some.about why i have to use 1 user to log in case the logic of program let me do that and i dont built this program i just mentain it .
basel jum'a

baselbj@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top