Create public database link to SQL Server using Windows Authentication - sql

Is it possible to create public database link to SQL Server using Windows Authentication from an Oracle DB?
I can create the link
CREATE PUBLIC DATABASE LINK DB_LINK CONNECT TO "domain\user" IDENTIFIED BY "password" USING 'tns_name_entry';
But when I try a select statement
Select * from dual#DB_LINK
I get the following:
ORA-28545: error diagnosed by Net8 when connecting to an agent
Unable to retrieve text of NETWORK/NCR message 65535
ORA-02063: preceding 2 lines from DB_LINK
28545. 0000 - "error diagnosed by Net8 when connecting to an agent"
*Cause: An attempt to call an external procedure or to issue SQL
to a non-Oracle system on a Heterogeneous Services database link
failed at connection initialization. The error diagnosed
by Net8 NCR software is reported separately.
*Action: Refer to the Net8 NCRO error message. If this isn't clear,
check connection administrative setup in tnsnames.ora
and listener.ora for the service associated with the
Heterogeneous Services database link being used, or with
'extproc_connection_data' for an external procedure call.
Error at Line: 9 Column: 20
I can connect to the db, so it's not an issue of connection. The heterogeneous service has been created, and the listener.ora and tnsnames.ora have been edited. I'm wondering if I'm getting the error because I'm using Windows authentication. Thanks.

Figured out my problem. It has something to do with Oracle12. You have to start the listener as the local account. Go into services --> right click properties of the listener --> Log On. Also you don't need the domain when creating the database link.

Related

sql server 2012 copy database failed between two instances on the same host

I am learning the sql server 2012 and got stuck when using the copy datase, trying to figure out why.
I created two instances on the same host, using administrator, windows authentication.
(the default instance:iZp0w14yqtvxcmZ, the second instance: iZp0w14yqtvxcmZ\instance2, try to copy database from the default one to the second one)
It failed at the last step: execute sql server agent job.
here is the error log from windows event viewer:
Message: Failed to connect to server iZp0w14yqtvxcmZ.
StackTrace: at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
at Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.OpenConnection(Server& server, ServerProperty serverProp)
InnerException-->Login failed for user 'NT Service\SQLAgent$INSTANCE2'.
Then I tried to add the login 'NT Service\SQLAgent$INSTANCE2' in the default instance. Then tried again and got another error:
Event Name: OnError
Message: An error occurred while transferring data. See the inner exception for details.
StackTrace: at Microsoft.SqlServer.Management.Smo.Transfer.TransferData()
at Microsoft.SqlServer.Dts.Tasks.TransferObjectsTask.TransferObjectsTask.TransferExtraObjectsViaSmoTransfer()
InnerException-->Windows NT user or group 'iZp0wd5ebkvswaZ\Administrator' not found. Check the name again.
But the Adminitrator does exist in the computer management -> local user and groups -> group, so I don't know what to do now. NEED HELP !!!
Thanks a lot!
after two-day's struggling, I figured it out. The sql server agent service should use a domain-based account for a multi-server environment. Also that account should be able to log in and perform the job.
I solved the issue changing the login method to system local account.
Two instances must have the same password and open, then in this case:
insert into [EI7-PC\SQLEXPRESS2].[MYCOMPANY].[dbo].[inventory] SELECT *
FROM [EI7-PC\SQLEXPRESS1].[MYCOMPANY].[dbo].[inventory] where itemno='10-0001'
The reason for the same password is unknown, this is per my experience. With two different password you may get an error about 'sa' failed to login.

how to use odbcDriverConnect when using shinyapps.io to show the tables retrieving from SQL by means of RODBC

I just asked a question about SQL not being linked when using shinyapps. “first argument“ error when using shinyapps.io, rodbc to show sql query result in web. This is about the error information "first argument is not an open rodbc channel" when I try to use shinyapps.io to share my SQL query results that I got from SQL database using RODBC.
Thanks a lot for Lars Br.'s help, I think I also need to try odbcDriverConnect instead of odbcConnect. I saw some suggestions from https://support.rstudio.com/hc/en-us/articles/225408367-Connecting-to-databases-using-RODBC-on-shinyapps-io, which could deal with my problem.
However, my problem is: as I am very new to all this stuff, I am confused about all the parameters in odbcDriverConnect. I tried it like:
ch <- odbcDriverConnect('driver=SQL Server;server=HANARB1P;database=testing;uid=****;pwd=****;TrustServerCertificate=true')
I have got the following information:
Warning messages:
1: In odbcDriverConnect("driver=SQL Server;server=HANARB1P;database=testing;uid=****;pwd=****;TrustServerCertificate=true") :
[RODBC] ERROR: state 08001, code 17, message [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
2: In odbcDriverConnect("driver=SQL Server;server=HANARB1P;database=testing;uid=****;pwd=****;TrustServerCertificate=true") :
[RODBC] ERROR: state 01000, code 53, message [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()).
3: In odbcDriverConnect("driver=SQL Server;server=HANARB1P;database=testing;uid=****;pwd=****;TrustServerCertificate=true") :
[RODBC] ERROR: state 01S00, code 0, message [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute
4: In odbcDriverConnect("driver=SQL Server;server=HANARB1P;database=testing;uid=****;pwd=****;TrustServerCertificate=true") :
ODBC connection failed
So far, I only have DSN: HANARB1P. I do not know what driver, sever and database in odbcDriverConnect are. I cannot find the definitions online. Could someone explain to me?
I also find some information probably useful from http://docs.rstudio.com/shinyapps.io/applications.html. It saids: "If your shiny application needs to access a database that you have running behind your organization’s firewall, your IT department will need to know which servers will be connecting through the firewall. Below are the shinyapps.io IP addresses you must whitelist:". I do not know if this is related to my problem. And if so, how I can set up those things?
I think you need to try changing the driver types as mentioned in the below article: https://support.rstudio.com/hc/en-us/articles/225408367-Connecting-to-databases-using-RODBC-on-shinyapps-io . I am inferring that you are trying to access this database remotely, correct? If so, you need to be using the public IP address and port number for that database server- not the server's name.
con <- odbcDriverConnect('Driver=FreeTDS;TDS_Version=7.0;server="publicIPAddress";port"portNumber";database=testing;uid=****;pwd=****;')
Try with all 3 versions of TDS.
If this is your company's database, then you are most likely going to also have to allow access to it over the internet. Be careful though, doing this could have consequences and allow intrusions into your systems. Do you have an IT team that can handle this for you? It seems like you are unfamiliar with the impacts this could have to your company if done incorrectly, so I would leverage any skilled IT resources you have to do this correctly.
You will need to configure your router to allow port forwarding to your database (typically port 1433). This is the port number you will enter into your odbcDriverConnect call above. You will then also need to check your server's firewall settings- my understanding is that the standard rules are to block all incoming traffic to your SQL Server. This means you need to add an inbound rule that will allow your IP address to make a connection. You included a link to shinyapps.io in your post... are you hosting this application on shinyapps.io or just on your own computer? If you are deploying to shinyapps.io then you will also need to include those IPs listed in that article, in the allowed inbound connections I mentioned above.
My suggestion would be to work with your IT department on creating an whitelisted inbound rule on your firewall that only allows connections for those IPs needed to run your shiny app.

Microsoft Azure: There was an error while creating data connection 'SQL data connection'. Deployment to resource group failed

I am trying to create an Android Mobile app via the Azure app service and while doing so, I am trying to create a database, but I am getting the error 'there was an error while creating data connection 'SQL data connection'. Deployment to resource group failed'. Please help as soon as possible.
$
This error is due to server limit exceeding the quote associated with your account. Under all resources, check if there's a new SQL server created with a random name- you will need to delete that. Attempt to create again.
(just done- it worked!)
I've faced the exact issue.
First time it failed giving the error - Data Connection Creation Error..!
When Configuring for the first time it didn't work for me.
i.e.,
Creating a Database
Creating a New Server
Entering Server Admin Login
Entering Server Admin Password
I've noted down all the above information.
Tried Second time setting up the Connection String with the above details IT WORKED.
Hope this information helps.

Access to the remote server is denied because the current security context is not trusted

I have a service broker which calls a stores procedure sp_dequeue
queue -->
ACTIVATION
( STATUS = ON,
MAX_QUEUE_READERS = 1,
PROCEDURE_NAME = sp_dequeue,
EXECUTE AS 'Username'
);
In my sp_dequeue i am inserting record in to Linked server...
So when i am calling sp_dequeue from the magmnt studio it works fine. But when its called automatically via service broker i get this error msg :
"Access to the remote server is denied because the current security context is not trusted.".
In my linked server property i have checked "Be made using this security constraint" and provided oracle userid and pwd also i have added 'Username' mapping to oracle server.(Both username and pwd of oracle/SQL are different)
I googled for this error tried mostly all combination.
Pls do help me in sloving this problem.
using Sql server 2005 and oracle 10g
The explanation is given at Why does feature … not work under activation?. One solution is to enable TRUSTWORTHY, as you did. Another one is to use code signing, see Signing an activated procedure. Code signing is more complicated to deploy, but is required in very strict security environments because the TRUSTWORTHY flags opens the path to privilege escalation from dbo to sysadmin.

SQL Server 2008 Error 233

I'm creating new login in SQL Server 2008 with following sql script:
CREATE LOGIN [xyz] WITH PASSWORD='xyz',
DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english],
CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
It creates new login successfully. But when I try to login with it using SQL Server Management Studio it fails saying:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
What's wrong? How do I solve this issue?
Here is how I done it, maybe it works for you too.
login Microsoft SQL Server 2012 with windows authentication.
right-click onto the server name in Object Explorer and click Properties
In the new tab click Security
select SQL Server and Windows Authentication
Ok
Close the SQL server management studio.
start+run
write services.msc
search for SQL there and restart all services.
that works for me.
It's also possible that you're trying to use SQL Server Authentication without having enabled it. To fix this, right-click Properties on your server instance in SQL Server Management Studio, and update the security settings to include "SQL Server and Windows Authentication mode".
Looks like you're trying to connect using named pipes, but SQL Server is not listening on that protocol. See MSDN.
The two fixes MSDN suggests are:
Connect using TCP/IP, or use the SQL
Server Configuration Manager to
enable remote connections using named
pipes.
Using SQL Server Configuration
Manager on the client computer, move
TCP before named pipes in the
protocol order list.
I had a similar issue:
1. log in as the master user or windows authenticated user.
2. right click on the database --> properties --> security -->
3. change Windows Authentication mode to "SQL server and windows authentication mode" by clicking on the radio button. (if it is not)
4. restart the server
I had the same issue when i first setup SQL Server 2014 on my local machine.
In my case the solution was to set a correct defualt database.
Login with Administrator in SQL Server
Go to Securities >> Logins >> select your user name and go to properties
From Status >> uncheck user account lock check box
Change password for the user
Restart the sql server and login with your username.
I was facing the same error.
I've resolved the error by following below mentioned steps:
Disable named pipes and restart sql services.
After restart sql server I enabled names pipes and did a sql server restart again (Link for Step 1 and 2)
Connect to SQL server via studio.
Right click on SQL instance --> Properties --> Connections --> "Set the Maximum number of 5. concurrent connections to '0' ".
Save the change.
Restart the SQL server if possible. (Link for step 3 to 6)
I hope this will help someone
This is might not be a connection issue . Check your default database and if that is online . More commonly this issues seen when the default database will be offline or not exists . If your default database other than master ,better check this option.
I got a way to go around the problem.
Open one instance and login using the windows authentication
allow sql and windows auth both by right cliking on the db server.
Open second instance and login using sql authentication.
bingo the sql authenticated instance open .. :)
Actually in this way we cheat the sql authenticated instance as it tries to find an already running instance.. worked fr me.. good luck
I tried most of the solution but was not able to solve it until I found this URL which says to do the following:
Open SQL Server Management Studio and run the these queries:
sp_configure 'show advanced options', 1;
go
reconfigure
go
sp_configure 'user connections', 0
go
reconfigure
go
The reason why we got this error is that the user connections was reset to 1, so only one user was able to connect with the SQL server.
just a simple query worked for. I hope this will work for others as well.
I have not used the script style, but login through GUI I encountered the same error code. I had entered wrong user name and this is why I was getting the Sql Server, Error: 233. In order to resolve this, you should input the following information:
Server Name: MachineName\SQLEXPRESS
Authentication: SqlServer Authentication
User Name: Assigned user-name or simply sa
Password: xyzpqr
NOTE: Here I have wrote above data for demo purpose only, actual data is your machine & software's properties.
According to: https://msdn.microsoft.com/en-us/library/bb326280.aspx
Go to --> Remot setting
Go to "Remote" tab
in "Remote Assistance", Tick "Allow Remote Assistance connection to this computer", Click the "Advance" button and tick the "Allow..." and in the "Invitation" set the "30 days"
Then in the "Remote Desktop" part
Just tick "Allow remote connection to this computer"
After following the examples here and still not getting in, I found that my sa login was disabled. The following got me in:
Logged back in under windows authentication.
Expanded Security Tab
Expanded Logins Tab
Right-clicked sa and selected Properties
Went to the Status Tab
Under Login: Clicked 'Enabled' radio
Restarted Server and logged in as sa.
This assumes you have set sa password already using
ALTER LOGIN sa WITH PASSWORD = '<enterStrongPasswordHere>' ;
"A connection was successfully established with the server, but then an error occurred during the login process."
I was getting this problem from sqllocaldb when used from within Docker. The problem was the Docker image was not allocated enough memory. Increasing the memory actually fixed the problem.