Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Windows Log-in User Name for a SQL Log in User

By using sp_who2 I can get a list of current log-in users and machine names. Some users are using SQL Server log-in user name such as sa. Is there any way I can get the windows log-in user name for the SQL log-in users?

If there is no way to get Windows log-in users from the machine names, can I use WMI class or C# to get find out the Windows log-in user names by their machine names?

My SQL server is Microsoft SQL Server 2005 and Windows is Server 2003.

like image 861
David.Chu.ca Avatar asked Mar 15 '09 17:03

David.Chu.ca


People also ask

How do I find my SQL Server login username?

SQL Server USER_NAME() Function The USER_NAME() function returns the database user name based on the specified id. If no id is specified, this function will return the name of the current user.

How do I find my Windows Authentication username and password in SQL Server?

In Object Explorer, expand the SQL Server, expand Security, right-click Logins, and then select New Login. For the Login name, enter the Windows user name in the domain\username format. When using this adapter with BizTalkBizTalkMicrosoft BizTalk Server allows connecting diverse software, then graphically creating and modifying process logic that uses that software. BizTalk Server also enables information workers to monitor running processes, interact with trading partners, and perform other business-oriented tasks.https://learn.microsoft.com › core › introducing-biztalk-serverIntroducing BizTalk Server - Microsoft Learn, then the login name you enter, is the identity of the host instance account.

How do I find my SQL username and password?

So for example, to show MySQL users' username, password and host, we'll modify the sql query to accordingly as such: mysql> select user, password, host from mysql. user; The above sql query will present you with a list of users and their respective user name, password and database host.

Can a SQL Server login use Windows Authentication?

SQL Server supports two authentication modes, Windows authentication mode and mixed mode. Windows authentication is the default, and is often referred to as integrated security because this SQL Server security model is tightly integrated with Windows.


1 Answers

To get the user and machine name use this:

SELECT HOST_NAME() AS HostName, SUSER_NAME() LoggedInUser
like image 50
JohnM Avatar answered Oct 04 '22 23:10

JohnM