Can I use a domain account in OPENDATASOURCE() - sql-server

I have been trying and failing to use a domain account in SQL Server's OPENDATASOURCE().
I've tried many variations, including the following:
OPENDATASOURCE ('SQLNCLI', 'Data Source=<server name>; User ID=<domain>\<user>; Password=<password>' )
I've also tried escaping the backslash like this:
OPENDATASOURCE ('SQLNCLI', 'Data Source=<server name>; User ID=<domain>\\<user>; Password=<password>' )
I get following error message in the first case:
Msg 18456, Level 14, State 1, Line 1
Login failed for user '<domain>\<user>'
In the second case, I get the same except that I see both backslashes in the error message.
Is what I'm trying to do possible?
Also, the password includes a backtick (`) character. Is that forbidden in OPENDATASOURCE?

No OleDb drivers support using Windows Auth with provided username/password. The only way to use Windows Auth is by impersonating the user, injecting the user's credentials in the Windows Credential Store, or using runas /netonly.

EDIT: To use a backtick or special char in the password you need to encapsulate in double quotes
For example, if your password is "`password", you may need to enter like:
OPENDATASOURCE('SQLNCLI', 'Data Source=server_name;uid=domain\username;pwd="`password"')

Related

GRANT on db with a separator in name not working

I have a problem on my Debian server with MariaDB on it.
I'm trying to grant all privileges to a user ('agricoop') on my database called extranet-agricoop.
I'm writing : GRANT ALL PRIVILEGES ON extranet-agricoop.* TO 'agricoop'#'localhost';
I get the error message : "You have an error in your SQL syntax [...] near 'extranet-agricoop.* TO 'agricoop'#'localhost'' at line 1"
It worked for my other users on other table but just not for that one. If I select ‘*.*´ it works so for me the problem seems to come from the name of the db. I've tried to escape the separator but still not working.
Have you got any idea ?
Thanks :)
Identifiers have to be quoted if it contains one or more character which is not part of [a-z,A-Z,0-9,$,_] (or isn't a unicode character > 0x0080).
If sql_mode ANSI_QUOTES is set, you have to use double quotes ("), if sql_mode is MSSQL square brackets([..]) have to be used.
Example:
GRANT ALL ON `better-use-dash-than-minus`.* TO foo#localhost

Adaptive Server requires encryption of the login password on the network in Oracle SQL Developer Tool

I am getting error while connecting to my database in Oracle SQL developer tool
"Adaptive Server requires encryption of the login password on the network"
Can any paramater be set in the tool to fix it out or any other suggestions ?
Maybe look at this link which all the possible parameters:
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc39001.0605/html/prjdbc/prjdbc14.htm
Most likely you need
ENCRYPT_PASSWORD=true
net password encryption reqd
the default value is 0
if set to 2
then maybe the error reported in your case
we should pass the ENCRYPT_PASSWORD=true:
example python:
import glob
driver_name='com.sybase.jdbc4.jdbc.SybDriver'
driverpath=r"C:\Users\RameshPonnusamy\AppData\Roaming\DBeaverData\drivers\drivers\sybase\jconnect\jconn4.jar"
import jaydebeapi
jclassname=driver_name
url="jdbc:sybase:Tds:{h}:{pr}".format(h=host,pr=port,db=database)
driver_args={'user': username, 'password':password,
'database': database,
'ENCRYPT_PASSWORD':'true'}
jars=glob.glob(driverpath)
conn = jaydebeapi.connect(jclassname=jclassname,url=url, driver_args=driver_args, jars=jars)
If you are using IDE(Ex:Dbeaver)
Update ENCRYPT_PASSWORD parameter as true
right click on connection
-->edit_connection(if it is already saved)
-->Driver Properties-->click on value column cell of ENCRYPT_PASSWORD
***type true*** and click ok

connect to mssql with password that containts #

I am using nodes mssql module in order to connect to mssql database. However my password contains # and the pattern to the connection is
mssql://username:password#localhost/database
It throws connection error. I assume it is because it sees # so content after it it takes as localhost and so on.
Is there a way how to connect there with password that contains #?
Thanks
From MSDN:
certain symbols must be enclosed by double quotation marks (") or square brackets ([ ]).
Use these delimiters in Transact-SQL statements when the SQL Server login, user, role, or password has the following characteristics:
1.Contains or starts with a space character.
2. Starts with the $ or # character.

Oracle create db link using a proxy schema

So I want to create a database link in oracle, my username is jefferson and I want to connect trough opms so I was told to do this.
create database link tmpp connect to jefferson[opms] identified by nothing using $something ;
For some reason when I try to use [] syntax it just tells me indentified is missing. Why is this not working, I was told to do it this way but I can't find any help in the official documentation for [] usage or the correct syntax.
You can create a fixed-user database link like this, but you need to enclose the entire proxy user identifier in double-quotes; and because it's now a quoted identifier the case has to match the DBA_USERS username, which is uppercase by default:
create database link tmpp connect to "JEFFERSON[OPMS]" identified by nothing using ... ;
As noted in MOS document 1477939.1 you can't create a connected-user database link (which you aren't trying to do); and the 30-character limit on identifiers applies, so the total length of both usernames plus the square brackets has to be 30 characters or less (which is also fine in your example).
However, as discussed in this related question, this functionality is currently broken in 11.2.0.4 and above because of bug 19191702.

R and database Roracle

I am using Rstudio (or R) with the package ROracle to connect to db. However I have the following error message
Error in .oci.Connect(.oci.drv(), username = username, password = password, :
ORA-12154: TNS:could not resolve the connect identifier specified
One possible solution is to add the following line to the .Renviron file. But I guess my R does not read this file. How can I be sure, or force R to read .Renviron? (I am using Windows.)
Some other suggestion from Oracle are here.
I am so grateful for every hint.
You can read the .Renviron file with the readRenviron function. Just make sure you enter the correct file path.
readRenviron(".Renviron")

Resources