Connect different Windows User in SQL Server Management Studio (2005 or later)

后端 未结 9 1732
我寻月下人不归
我寻月下人不归 2020-11-30 16:03

Is there a way in SQL Server Management Studio 2005 (or later) to change the Windows Authentication user (as you could in SQL Server 2000 and older)?

This is the gen

相关标签:
9条回答
  • 2020-11-30 16:26

    Hold shift and right click on SQL Server Mangement studion icon. You can Run as other windows account user.

    0 讨论(0)
  • 2020-11-30 16:26

    A bit of powershell magic will do the trick:

    cmdkey /add:"SERVER:1433" /user:"DOMAIN\USERNAME" /pass:"PASSWORD"
    

    Then just select windows authentication

    0 讨论(0)
  • 2020-11-30 16:27

    There are many places where someone might want to deploy this kind of scenario, but due to the way integrated authentication works, it is not possible.

    As gbn mentioned, integrated authentication uses a special token that corresponds to your Windows identity. There are coding practices called "impersonation" (probably used by the Run As... command) that allow you to effectively perform an activity as another Windows user, but there is not really a way to arbitrarily act as a different user (à la Linux) in Windows applications aside from that.

    If you really need to administer multiple servers across several domains, you might consider one of the following:

    1. Set up Domain Trust between your domains so that your account can access computers in the trusting domain
    2. Configure a SQL user (using mixed authentication) across all the servers you need to administer so that you can log in that way; obviously, this might introduce some security issues and create a maintenance nightmare if you have to change all the passwords at some point.

    Hopefully this helps!

    0 讨论(0)
  • 2020-11-30 16:32

    One other way that I discovered is to go to "Start" > "Control Panel" > "Stored Usernames and passwords" (Administrative Tools > Credential Manager in Windows 7) and add the domain account that you would use with the "runas" command.

    Then, in SQL Management Studio 2005, just select the "Windows Authentication" and input the server you wanna connect to (even though the user that you can see greyed out is still the local user)... and it works!

    Don't ask me why ! :)

    Edit: Make sure to include ":1433" after the server name in Credential Manager or it may not connect due to not trusting the domain.

    0 讨论(0)
  • 2020-11-30 16:32

    For Windows 10: Go to the Sql Management Studio Icon, or Short Cut in the menu: Right Click > Select Open File Location

    Hold Shift and right Click the shortcut, or ssms.exe file that is in the folder. Holding shift will give you an extra option "Run as different user":

    This will pop up a login box and you can type the credentials you would like your session to run under.

    0 讨论(0)
  • 2020-11-30 16:38

    The only way to achieve what you want is opening several instances of SSMS by right clicking on shortcut and using the 'Run-as' feature.

    0 讨论(0)
提交回复
热议问题