I tried to execute a stored procedure. But I this error below, at every stance of execution:
Msg 18456, Level 14, State 1, Line 3 Login failed for user 'NT
AUTHORITY\ANONYMOUS LOGON'.
Thank you.
This is what I try to execute:
USE [Artikelen]
GO
DECLARE #return_value int
EXEC #return_value = [dbo].[BerekenSKU]
#loc = N'AM',
#lev = N'3436',
#reset = true
SELECT 'Return Value' = #return_value
GO
I am using Microsoft SQL 2014
Error shows that there is credential issue. Please check this link.
This message indicates that you are attempting to access the linked
server by using Windows NT authentication to impersonate the client
connecting. Refer Link
Look at the stored procedure in question. The login is failing at the
linked server because whoever is calling it doesn't have mapped
credentials set up.
Refer this links:
sqlcmd: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'
http://www.sqlservercentral.com/Forums/Topic548200-146-1.aspx
http://www.sqlservercentral.com/Forums/Topic1523177-1550-1.aspx
http://www.sqlservercentral.com/Forums/Topic246883-110-1.aspx
http://www.sqlservercentral.com/Forums/Topic246883-110-1.aspx
Related
I'm also new to DevOps, but let me see if I can explain my situation, also if anyone has any advice on doing post deployment scripts and can share their experiences I will be most grateful.
I use SQL Source control from Redgate, Git and Azure DevOps. I have managed to get the build and deployment working perfectly. Additionally we would like to make some data changes so we have additional (Data Change) scripts we wish to run. Linking these tables as static data is not an option as we would end up having most tables linked and end up with extremely timeous build and deploy times.
The script inserts data to a table, thereby triggering the insert trigger which calls a procedure to write to an audit table. The actual error from the deployment log is:
Task : DbUp Migration
2021-01-25T12:52:17.2629353Z Description : Runs SQL Server change scripts, and only those which have not been run already.
2021-01-25T12:52:17.2629405Z Version : 2.1.4
2021-01-25T12:52:17.2629671Z Author : Johan Classon
2021-01-25T12:52:17.2629721Z Help : [More Information](https://github.com/johanclasson/vso-agent-tasks)
2021-01-25T12:52:17.2629775Z ==============================================================================
2021-01-25T12:52:19.6610608Z Beginning database upgrade
2021-01-25T12:52:19.6689401Z Checking whether journal table exists..
2021-01-25T12:52:19.6728756Z Journal table does not exist
2021-01-25T12:52:19.7775348Z Executing Database Server script '001 - EX27605 - rdl.sql'
2021-01-25T12:52:19.7908913Z Checking whether journal table exists..
2021-01-25T12:52:19.7929056Z Creating the [dbo].[_SchemaVersions] table
2021-01-25T12:52:19.8077238Z The [dbo].[_SchemaVersions] table has been created
2021-01-25T12:52:20.2264323Z ifExists - rdl_Rule_Definition_Lookup - rdl_Code = "9900226e"
2021-01-25T12:52:20.2277308Z insert - rdl_Rule_Definition_Lookup - rdl_Code = "9900226e"
2021-01-25T12:52:20.2805780Z SQL exception has occured in script: '001 - EX27605 - rdl.sql'
2021-01-25T12:52:20.2942912Z ##[error]Script block number: 0; Block line 74; Message: Trig_After_Ins_Upd_Del_rdl_Rule_Definition_Lookup
2021-01-25T12:52:20.4528752Z ##[error]System.Data.SqlClient.SqlException (0x80131904): p_dte_Audit_Backend: (Line: 108) [dte_admin]
So the 1st error refers to line 74 of the trigger, if I read this correctly which is a commit on a procedure call to write to the audit table, line 108 of my procedure sets the userID:
DECLARE #user VARCHAR(40)
SET #user =
CASE
WHEN suser_sname() = 'NT SERVICE\SQLAgent$'+##servicename THEN 'dte_admin'
WHEN suser_sname() = 'NT SERVICE\SQLSERVERAGENT' THEN 'dte_admin'
ELSE suser_sname()
END
--###############
select #udt_Audit = udt_Audit
from udt_User_Detail (nolock)
where udt_User_Id = #user--suser_sname()
--select #udt_Audit = udt_Audit from udt_User_Detail
--where udt_User_Id = suser_sname()
if ##rowcount = 0
begin
declare #udt_User_Id varchar(30)
set #udt_User_Id = suser_sname()
The last line being line 108.
Important to note that dte_admin is a login on the SQL Server, it is a sysadmin account and mapped to the database, the dte_admin user is also a user at database level and exists as a user in my user table udt_user_detail.
During the build and deployment I am using variables and they are set to dte_admin username and password.
My question is then, why does this fail with this user?
Deployment Pipeline result
Have tried:
EXEC master.dbo.sp_addlinkedserver
#server = N'ADSI',
#srvproduct=N'Active Directory Services',
#provider=N'ADsDSOObject',
#datasrc=N'server_name.your_domain.com'
EXEC master.dbo.sp_addlinkedsrvlogin
#rmtsrvname=N'ADSI',
#useself=N'False',
#locallogin=NULL,
#rmtuser=N'your_domain\domain_user',
#rmtpassword='********'
SELECT *
FROM OPENQUERY (ADSI, 'SELECT *
FROM ''LDAP://DC=your_domain,DC=com''')
Getting this error:
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query "SELECT * FROM 'LDAP://DC=your_domain,DC=com'" for execution against OLE DB provider "ADsDSOObject" for linked server "ADSI".
I have already confirmed mine and the SQL Server Service domain accounts have read access to AD, and that the "Allow inprocess" is enabled on the ADsDSOObject provider is selected.
Any thoughts would be appreciated.
Every example I could find had: LDAP://DC=your_domain,DC=com as syntax. Well for our server (and maybe other's) it is: LDAP://DC=your_domain,DC=internal
As suggested by someone, I used the Softerra LDAP browser (free) and opened the server, clicked on the top node and found distinguished name entry listed as: DC=your_domain,DC=internal
Once I made that change, I could see the AD data.
Every time I'm launching SQL server I run a script that destroys my little local database, refills it with example data, destroys some logins that were artificially created using this script.
exec sp_addlogin #loginame = 'strong', #passwd ='strong', #defdb =KornDurnDB_new;
exec sp_adduser #loginame = 'strong', #name_in_db = 'strng';
To this login I give ALL grants(according to ANSI-92 standart), but It is not enough to authorize using this login, when sql management studio launches. Sql management studio returns me error 18456.
What can a add to make a login with that account and password?
UPDATED(SOLUTION): I have just reinstalled MS SQL server with other installaton properties and its working
You might be creating a user in the master database instead of the KornDurnDB_new database. Try:
exec sp_addlogin #loginame = 'strong', #passwd = 'strong', #defdb = KornDurnDB_new;
use KornDurnDB_new;
exec sp_adduser #loginame = 'strong', #name_in_db = 'strng';
Note that both sp_addlogin and sp_adduser are obsolete. Their replacements are create login and create user.
When I try to run the command:
EXEC master..sp_addsrvrolemember #loginame = N'sa', #rolename = N'serveradmin'
GO
I get the error:
Msg 15405, Level 11, State 1, Procedure sp_addsrvrolemember, Line 45
Cannot use the special principal 'sa'.
Ideas/suggestions welcome.
'sa' is a reserved login for the sysadmin; it's already a member of the sysadmin group, which trumps all other groups. You don't need to add it to any roles, so why are you trying to do that?
I've created a logon trigger in MS SQL that needs to check dm_exec_sessions for a login. This login is the user listed in the connection string and has owner right to the database. If the login is verified, I need it to update a specific table and send an email.
So far I've done just the following piece and it disabled my web site. The error I get is: "Logon failed for login 'dev' due to trigger execution. Changed database context to 'mydatabase'. Changed language setting to us_english."
Any idea what I did wrong? Thanks,
Risho
CREATE TRIGGER TDY_Assets_Notification
ON ALL SERVER WITH EXECUTE AS 'dev'
FOR LOGON
AS
BEGIN
IF ORIGINAL_LOGIN()='dev' AND
(SELECT COUNT(*) FROM sys.dm_exec_sessions
WHERE is_user_process = 1 AND
original_login_name = 'dev') > 1
UPDATE Assets_TDY
SET Suspense = 1, Warning = 1
WHERE (Date_Returned IS NULL) AND (GETDATE() >= DATEADD(day, 3, Date_Return))
END
Try connecting with the Dedicated Administrator Connection. That will give you an opportunity to disable the faulty logon trigger.
DISABLE TRIGGER [TDY_Assets_Notification] ON ALL SERVER