Azure SQL Database Active Directory password authentication using powershell - azure-active-directory

I am trying to login in Azure SQL active password authentication using cloudhsell
below is the error I am facing mentioned in the screen shot.I am not able to understand is this the authentication issue or syntax issue in my script.
$cxn.open will open the connection but before that only I am facing issue.
After that I need to exectue the below commands
$cmd = New-Object System.Data.SqlClient.SqlCommand($query, $cxn)
$cmd.CommandTimeout = 120
$cmd.ExecuteNonQuery()
$cxn.Close()
Objective is to login to Azure SQL using active password auth and write some SQL query and close the connection.This thing I need to do in devops inline script task but it is falling in cloudshell itself.
Error - detail mentioned in the below diagram, please let me know how to correct it.
Kindly let me know is there any other script is there.

I'm not sure if this will fix all your issues, but there is a syntax error there.
In your connection string you put authentication="Azure Active Directory""
that is a syntax error because your double quote actually ends the string...
get rid of the "" around the azure active directory. like. authentication=Azure Active Directory";
that would at least get rid of the syntax error.

try to use Microsoft.Data.SqlClient

Related

Azure SQL Server Connection Error Despite Correct Credentials - Error Number:18456,State:1,Class:14

I have created a new SQL Database on Azure, and have copied the connection string directly from the Azure Portal.
On my .NET application, when I am trying to run 'Update-Database' command in Package Manager Console to commit the migration, I receive the following error:
Error Number:18456,State:1,Class:14 Login failed for user
'benhayward'.
Extra Information:
- I have changed my database admin password.
- I have confirmed that the log-in credentials are correct.
- I am on the Azure free trial.
Any advice or assistance on this would be greatly appreciated.
Ok a slightly embarrassing solution, but the reason this wasn't working is because of the curly brackets surrounding the password, as LeonYue suggested.
I had the same issue. The problem was that I had two entirelly different connection strings with the same name in different config files. The right one in app settings was being overwritten by another connection string in my user secrets. As soon as I deleted connection string from my secrets, everything went fine without any errors. Hope my solution will help the others

SQL Server login timeout expired when running sqlcmd

Today I have some strange error on SQL Server. Something like this:
I don't know what I should do. This is happening when I want to run query more than 200MB. But I guess, the size doesn't matter. Can anyone guide me to fix this problem?
And, for some reason, I can't export SQL Server data for more than 100MB, so can anyone help me ?
Your error messages say a couple of different things:
Login timeout expired
... Server is not found or accessible ...
Could not open connection to SQL Server
If you look over the command parameters for sqlcmd here.
You're passing in s which is col_separator, rather than server which is S (note the capitalization).
Next you're probably going to need an authorization strategy, whether that is E for Integrated Security, or using U and P for userid and password respectively.
Try those and see what you're getting.
You could, of course, always try using SSMS rather than sqlcmd.
Edit: Looks like integrated security is by default, so you don't need to specify E unless you just want to.

Setup Azure MSSQL Database in Ejabberd server?

I'm developing chat application, I'm using ejabberd for my project. I installed ejabberd server(16.06) successfully and it performing good in auth method as internal. But it is not working when I'm changed auth method as sql. These are the things I'm changed in ejabberd.yml file
default_db: sql
auth_method: sql
## ODBC compatible or MSSQL server:
##
sql_type: mssql
sql_server: "Server=azure_server_name;DSN=DB_Name;UID=azure_DB_username;PWD=azure_DB_password"
sql_pool_size: 10
sql_keepalive_interval: 28800
mod_mam:
iqdisc: one_queue
db_type: sql
default: always
I'm getting following error for while I'm register new user and admin login into web admin portal
ejabberd_auth:is_user_exists:316 The authentication module ejabberd_auth_sql returned an error
when checking user <<"newuser">> in server <<"localhost">>
Error message: {timeout,{p1_fsm,sync_send_event,[<0.390.0>,{sql_cmd,{sql_query,{sql_query,<<"Q9525209">>,#Fun<sql_queries.9.38301790>,#Fun<sql_queries.10.38301790>,#Fun<sql_queries.11.38301790>,{sql_queries,145}}},3534866},60000]}}
I'm used register command:
bin>ejabberdctl register "newuser" "localhost" "password"
Thanks in advance. Please add your ideas and suggestions to resolve this issue.
Again- I am no Ejabberd expert- I imagine someone might have more experience with this; However, it seems that you're confusing Register which I assume is an action to create a login on the Ejabberd platform with the login that is being used on the database. (Or I'm misinterpreting your comments. One of the two.)
You will need to use a username/password combination that exists on the Azure SQL Database in your connection string.
Additionally, you might try the following connection string :
sql_server:"Server=tcp:azure_server_name.database.windows.net;DSN=DB_Name;UID=azure_DB_username;PWD=azure_DB_password"

Login failed for user 'sa' while trying to create datasource with Railo

So I'm trying to setup Railo and I want to add a datasource.
For the database I'm using Microsoft SQL server Management Studio.
But now I've run into the classical problem: "Login failed for user 'sa'. ClientConnectionId:afd80ac2-0744-4a7d-a9f7-083d93adee0d"
What I've done so far:
With the SQL Server Configuration Manager in the TCP/IP settings I enabled the IPs I had to.
I set the password for the user 'sa' in MSSQL and I added a user mapping for the table I want to use.
I made the user 'sa' the owner of the DB i want to connect to
Restarted the SQL service, my computer and Railo multiple times.
I'm pretty much out of ideas.
After Leigh mentioned in the comments to look at my logs it had the following message: "Login failed for user 'max'. Reason: Failed to open the explicitly specified database 'test'. [CLIENT: 127.0.0.1]"
I then tried to make a connection without mentioning a database and that worked.
I would also point to Leigh's answer here which explains how to turn Mixed-Mode authentication on, as this can also cause this error. Since the cause of this isn't on Railo/Lucee's end, this issue still arises in 2018.
I just don't want a useful answer to get lost to history, nor plagiarize an answer I barely found.

change some field type cause exception when access the database

I change some field from char(50) to be VARCHAR(MAX).
I did this change from the visual studio.
Now, i trying to access to the database and i get the exception
Cannot open user default database.
Login failed. Login failed for user
'NT AUTHORITY\NETWORK SERVICE'.
my knowledge on sql is very pure - and i dont know how to solve this problem.
I used this - and still nothing work fine.
Thanks for any help.
Update: I reverse the change that i made thru the visual studio - and all work fine.
I made the change in same way and the exception appear again.
Is there some other way to do this simple change ?
Basically because your WCF server app runs under the network service account it cannot use windows authentication to connect to SQL. Can you not use SQL username and password as the connection string?

Resources