I'm going to connect to the internal Windows Server from outside the company via SSH (OpenSSH) PortForward and work with the SQLServer DB.
The language used is C#.
SQLServer is connected with SQLServer authentication.
After connecting to the corporate Windows Server,
I am working on the DB of SQLServer, but sa users can work with DB, but if I try to work with SQL users with logins (hereinafter referred to as dedicated users) created by SSMS, it will be an exception.
In summary,
Connect from your corporate LAN
sa user:OK
Dedicated User: OK
Connect to Windows Server via SSH PortForward via external Internet
sa user:OK
Dedicated user: NG=SQLServer DB operation is not possible.
I wonder if this kind of phenomenon is possible, but if there is one, I think the privileges of the dedicated user are insufficient, so which permissions should I grant?
Or is it necessary to devise a different way to create a connection string in C# than in the case of sa?
Please let me know.
--- Added 2022/4/30 21:50 ---
I'm sorry. This question was completely my misunderstanding.
As a result, this problem has been resolved.
I don't know exactly because I changed the settings, but the reason is probably because I entered the wrong SQL user login password.
I'm embarrassed because it's a very simple and elementary mistake.I will be careful in the future.
Sorry for taking the time to advise you.
c# ssh sql-server openssh
I don't really understand the meaning of SSH... (do you mean port forward connection to SQL Server?), but there are two modes of authentication for SQL Server.
One is SQL Server authentication, which is the mode to connect as a "user registered with SQL Server".sa This is the form of a user who connects with a username and password in the connection string.
The other is Windows authentication, and if you use it, it would be easier to manage using Active Directory, but it is also available to local users of devices running SQL Server.
In this case, it is necessary to register user information by registering Active Directory groups, etc., or to register users who have added them locally as individual SQL Server users.
In this case, the connection string will be Integrated Security= True or Integrated Security= SSPI and will not specify a username or password because the connection will be "Windows User Permissions Running the Program".
In either case, the user's privileges to connect to SQL Server must be a minimum, plus the appropriate privileges to the target database.
Since sa is an administrator user of SQL Server, you have operational privileges on all user databases from the beginning, but you must grant permissions individually to the users you add.
If you only need to read and write data, I think it would be easy to give the db_datawriter/db_datareader role.
For additional permission relationships, please refer to the official documentation (https://docs.microsoft.com/ja-jp/sql/relational-databases/security/authentication-access/database-level-roles?view=sql-server-ver15.
--- Added 2022/4/29 ---
When connecting with port forward, of course you must change the connection string.
If SQL Server is based on a connection to the default instance, you must specify the "port number to be transferred to the remote side on the local host" to connect to the remote side number 1433.
For example, if you want to transfer "Also, ""SQLServer DB operation is not possible."""" It says , but the fact that there are no actual error messages that you are receiving prevents you from resolving the problem. This is The port forward of OpenSSH is only about connecting the local communication port to the remote communication port.No unconfigured communication will flow, and only the communication thrown to the local listening port that you turned to for forwarding purposes will fly remotely. In terms of development based on OpenSSH port forward operation, as Sayuri said, "Connecting with SQL Server users" is a realistic solution, and it's like, "If sa is enabled in the first place, isn't it okay to be a SQL Server user?" If such information is not presented properly, I don't think you can get an appropriate solution.(With this range of information, I don't think it's about disclosing the secrets of a particular business unless it's presented in a strange way.)-L11433:(SQL Server remote IP address):1433
, the connection string must be "SQL Server is waiting at 11433 on the local host", so "Server=tcp:localhost,11433"
is not a local instance, "
·No connection to SQL Server itself
·Connected to SQL Server but not authenticated
·Connect to SQL Server and authenticate, but lack of permissions
It's because I can't separate them at all.
In other words, unlike the VPN connection, it does not "transmit all kinds of communication", so communication that occurs through AD authentication will not be established.(It's not possible to unilaterally allow a user to connect in the same capacity as he claims to be this user, even though he doesn't communicate properly.)I see)
In the case of Windows authentication only operation, sa users themselves cannot use it.
I will supplement your reply, although it is generally as you replied.It affects what the questioner says is a "dedicated user" and where the "dedicated user" can log in from.
According to creating users with SSMS, [User Type] has six users:
Windows users leave authentication to Windows.This means that SQL Server itself does not manage passwords and allows connections with Windows authentication.
"Did you choose ""Windows User"" for ""dedicated user""?"
"Connecting from your corporate LAN" says it's OK to connect, but more strictly speaking, the condition is that the user is authenticated with Active Directory.On the other hand, machines that do not participate in Active Directory will not be able to connect even if they are connected from a corporate LAN.
Similarly, the reason why the connection is not allowed via the "external net" may be because you are not participating in Active Directory and have not been authenticated by Active Directory?
If you want to accept connections from machines that do not participate in Active Directory, you must create a SQL User with Login and manage your own password.
596 GDB gets version error when attempting to debug with the Presense SDK (IDE)
577 PHP ssh2_scp_send fails to send files as intended
572 Understanding How to Configure Google API Key
884 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
566 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.