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!

User ID in SQL

Status
Not open for further replies.

Mungovan

Programmer
Oct 24, 2002
94
IE
Hi,

I need to save a user's NT ID into a table. Is there a way to automatically detect who is logged onto the system and then use this information in the server.

Kind regards,
Delcan
 
Just to get you started....

select user_id(), suser_id(), suser_name(), user_name(), Session_User, system_user, suser_sname()

Books on line is your friend. [smile]

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
George gave you the possibilities, you will need to read up in BOL to see whcihc one will give you exactly what you want as there are differnces between them.

"NOTHING is more important in a database than integrity." ESquared
 
Hey guys,

Thanks for the info that was great. I was looking at the BOL and couldn't find exactly what I'm looking for. Essentially I need to insert the machine name of the current user (because all user's will be logged onto the system as sa.)

Kind regards,
D
 
>> (because all user's will be logged onto the system as sa.)

This is a super bad idea.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
No one should ever log in as sa who is not an admin. This gives all rights to do anything to the system including dropping tables. If you ever have a sql injection attack (a distinct probablility if you are that lax about security, then you probably haven;t protected against this either.) then the person will have unlimited rights onyour database. Very very bad idea. ANd not only hackers are a problem. Do you really want disrguntled users to have full rights to the database?

"NOTHING is more important in a database than integrity." ESquared
 
Hi, thanks for the advice again. It' necessary in our system to have all users logged in as this for operational reasons. The Access front-end has it pretty safe.

Just on the last point, the function host_name() returns the name of the SQL server that the user's are connected to, rather than the name of the machine that the user's client session is running.

Cheers,
D
 
It' necessary in our system to have all users logged in as this for operational reasons.
It's never necessary to log all users in as sa, that's just a very poor setup.

The Access front-end has it pretty safe.
It's "pretty" safe? So you're not entirely sure? There's never any reason to assume that your system isn't susceptible to attack so you should always protect yourself as much as you can. Using the sa account is possibly the worst method you could use in this case.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top