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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the username..? 1

Status
Not open for further replies.

Kujen

Technical User
Oct 13, 2007
57
SE
Hi all,

The user is logged in to a non-trusted SQL-server database via ODBC. How can I retrive the username?

Kent J.
 
jrbarnett,

I thought I needed the SQL-username i Access so that I could filter the records for that specific user. I understand now that I can do that in SQL-server instead with CURRENT_USER as a filterparameter from the ODBC login.

My next problem i how to manage passwords if it's needed to let the user set the password themselves after a temporary password.

Kent J.

 
You can use the SUSER_SNAME function to retrieve the current SQL username in queries - this means that you can do them server side and cut down on network traffic between PC's and database server.

eg
Code:
SELECT f1, f2, f3, f4
from t1
WHERE t1.loginid = SUSER_SNAME()
ORDER BY f1


If you're storing a password for your application in the database, why not just use SQL password checking instead. I realise that in SQL 2000 its not great - no "force change at next login" and enforcement of complexity rules has to be done manually, but in 2005 its a lot better.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top