<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>logins - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/logins/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Wed, 28 Jul 2021 07:40:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>logins - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Fix:VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217;</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 30 Aug 2018 10:52:28 +0000</pubDate>
				<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL Server Connectivity Issue]]></category>
		<guid isPermaLink="false">https://techyaz.com/?p=2435</guid>

					<description><![CDATA[<p>Yesterday, one of the app user was complaining that he is not able to execute some of the queries and facing &#8220;VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217; . (Microsoft SQL Server, Error 300) &#8221; error while&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/">Fix:VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217;</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Yesterday, one of the app user was complaining that he is not able to execute some of the queries and facing &#8220;<em>VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217; . (Microsoft SQL Server, Error 300) &#8221; </em>error while executing the script. The screenshot of this error is given below.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-2436" src="https://techyaz.com/wp-content/uploads/2018/08/1-error-300-min.jpg" alt="SQL Server Error 300" width="723" height="193" srcset="https://techyaz.com/wp-content/uploads/2018/08/1-error-300-min.jpg 723w, https://techyaz.com/wp-content/uploads/2018/08/1-error-300-min-300x80.jpg 300w" sizes="(max-width: 723px) 100vw, 723px" /></p>
<h3><span style="color: #000000;">VIEW SERVER STATE Permission</span></h3>
<p>This is high level server-level privilege which must not be granted to everybody. Only administrators must have privilege to use view server state permission but we can assign this permission to some users who want to see server level state of your SQL Server instance. Once you will grant this access to any login, he can see result of all DMVs.</p>
<h2><span style="color: #000000;">Solution &#8211; ( Microsoft SQL Server, Error 300 )</span></h2>
<p>We got SQL Server error 300 ( VIEW SERVER STATE permission was denied ) because the login you are using to execute the script doesn&#8217;t have this permission. To fix this issue we will grant view server state permission to the login name. This section will explain how to grant view server state permission to a login.</p>
<h3>Grant VIEW SERVER STATE Permission</h3>
<p>We can assign this permission either using GUI in SQL Server Management Studio or we can simply execute a T-SQL command to get this done. I will explain both ways to assign this permission.</p>
<p><strong><span style="color: #993300;">Using GUI in SQL Server Management Studio</span></strong></p>
<p>Follow below steps to do it using GUI.</p>
<ol>
<li>Launch SQL Server Management Studio.</li>
<li>Connect to the SQL Server Instance.</li>
<li>Navigate to <strong>Security </strong>folder then expand<strong> Logins</strong></li>
<li>Right Click at your login name and choose <strong>Properties</strong></li>
<li>Click at <strong>Securables</strong> tab from left side pane.</li>
<li>In the bottom pane, scroll to the bottom and click at <strong>Grant</strong> option for <strong>View Server State </strong>value.</li>
<li>Now click on apply to close the window. You can now ask your user to test the script again. This time it will work.</li>
</ol>
<p><strong><span style="color: #993300;">Using T-SQL statement in SQL Server Management Studio</span></strong></p>
<ol>
<li>Launch SQL Server Management Studio. Connect to the SQL Server Instance.</li>
<li>Open <strong>New Query </strong>window</li>
<li>Run below T-SQL statement</li>
</ol>
<pre><em><strong><span style="color: #0000ff;">USE master</span></strong></em>
<em><strong><span style="color: #0000ff;">GO</span></strong></em>
<em><strong><span style="color: #0000ff;">GRANT VIEW SERVER STATE TO "LoginName"</span></strong></em></pre>
<p>Once you execute above command, you will have view server state permission on your login name. You can resolve <em><strong>SQL Server error 300</strong></em> <strong><em>VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master </em></strong>issue by following above steps given in this article.</p>
<h3>Revoke VIEW SERVER STATE Permission</h3>
<p>If you have identified anyone who must not have this permission then you can go ahead and revoke his access post getting proper approvals. Make sure that identified login does not have any business justification before revoking his access. Once you have decided to go ahead to remove view server state permission then you should run below T-SQL statement to get this done. Below steps will tell you how to revoke view server state permission of any login.</p>
<p><em><strong><span style="color: #0000ff;">USE master</span></strong></em></p>
<p><em><strong><span style="color: #0000ff;">REVOKE VIEW SERVER STATE TO &#8220;LoginName&#8221;</span></strong></em></p>
<p><em><strong><span style="color: #0000ff;">GO</span></strong></em></p>
<p>View SERVER STATE permission has been revoked for identified login post successful execution of above statement.</p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><em><span style="color: #800000;"><strong>Read More:</strong></span></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/sql-server-alwayson-interview-questions-answers/" target="_blank" rel="noopener">SQL Server AlwaysON Interview Questions &amp; Answers</a></strong></li>
<li><strong><a href="https://techyaz.com/interview-questions/sql-server-dba-interview-questions-answers/" target="_blank" rel="noopener">SQL Server DBA Interview Questions &amp; Answers</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/enhanced-database-failover-in-availability-group/" target="_blank" rel="noopener">Understanding Enhanced Database Failover in Always on Availability Group</a></strong></li>
<li><strong><a href="https://techyaz.com/interview-questions/sql-server-interview-questions/replication-qa-part-1/" target="_blank" rel="noopener">SQL Server Replication Interview Questions &amp; Answers</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/">Fix:VIEW SERVER STATE permission was denied on object &#8216;server&#8217;, database &#8216;master&#8217;</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fixview-server-state-permission-was-denied-on-object-server-database-master/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix Error 15190: There are still remote logins for the server &#8216;DBSERVER&#8217;.</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15190-there-are-still-remote-logins-for-the-server-dbserver/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15190-there-are-still-remote-logins-for-the-server-dbserver/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 18 Apr 2018 09:22:59 +0000</pubDate>
				<category><![CDATA[Linked_server]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[logins]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2109</guid>

					<description><![CDATA[<p>I got this error 15190 while renaming SQL Server Instance name. I was not able to drop the existing SQL Server instance name using sp_dropserver stored procedure and was getting error 15190. Full description of this error is given below.&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15190-there-are-still-remote-logins-for-the-server-dbserver/">Fix Error 15190: There are still remote logins for the server &#8216;DBSERVER&#8217;.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got this error 15190 while <strong><a href="http://techyaz.com/sql-server/troubleshooting/change-sql-server-instance-name/" target="_blank" rel="noopener">renaming SQL Server Instance name</a>.</strong> I was not able to drop the existing SQL Server instance name using <em>sp_dropserver</em> stored procedure and was getting error 15190. Full description of this error is given below.</p>
<p><em><span style="color: #ff0000;">Server: Msg 15190, Level 16, State 1, Procedure sp_dropserver</span></em><br />
<em><span style="color: #ff0000;"> There are still remote logins for the server &#8216;DBSERVER&#8217;.</span></em></p>
<h3><span style="color: #333399;">Error 15190 – Root Cause</span></h3>
<p><img decoding="async" class="size-full wp-image-2110 alignright" src="http://techyaz.com/wp-content/uploads/2018/04/error-15190.png" alt="error 15190" width="300" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/04/error-15190.png 300w, https://techyaz.com/wp-content/uploads/2018/04/error-15190-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/04/error-15190-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/04/error-15190-320x320.png 320w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<p>As we know we need to first drop the existing details of SQL Server instance name from metadata system table sys.servers and then add new instance name in order to change the instance name. I was doing the same and running below command to drop the old instance name.</p>
<pre><strong><span style="color: #0000ff;">sp_dropserver &lt;old_Name&gt;; </span></strong>
<strong><span style="color: #0000ff;">GO</span></strong></pre>
<p>I had received this error 15190 while executing above command and that is because of some remote logins present of the SQL Server instance.</p>
<p>If your database server has any remote login that you use for linked servers or some other purposes then you will get such issues. We need to drop all the remote logins to fix this issue and execute above command successfully.</p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>To fix this issue we need to identify remote logins and drop them before changing the SQL Server instance name. We will be using a system stored procedure <em>sp_dropremotelogin</em> to drop all remote logins from our SQL Server instance. Run below command to drop all remote logins from a default instance of SQL Server.</p>
<pre><strong><span style="color: #0000ff;">sp_dropremotelogin old_name; </span></strong>
<strong><span style="color: #0000ff;">GO</span></strong></pre>
<p>If you have named instance running on your database server then you can run below command. Make sure to change the name of server in place of <em>Old_DBSERVER\Instancename</em>.</p>
<pre><span style="color: #0000ff;"><strong>sp_dropremotelogin Old_DBSERVER\Instancename; </strong></span>
<span style="color: #0000ff;"><strong>GO</strong></span></pre>
<p>Once all remote logins have been dropped you can go ahead and perform your SQL Server Instance name change operation. Make sure to create remote logins for your linked servers or alias post changing the instance name.</p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/" target="_blank" rel="noopener">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/change-sql-server-instance-name/" target="_blank" rel="noopener">How to Change SQL Server Instance Name?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/configure-reporting-services-after-renaming-sql-server-instance/" target="_blank" rel="noopener">How to Rename SQL Server Instance that is running with SQL Server Reporting Services?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">Fix Error 15434: Could not drop login &#8220;domain\loginname&#8221; as the user is currently logged in</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Fix Error 15174: Login owns one or more databases. Change the owner of database before dropping the login.</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/sql-server-on-linux/change-hostname-red-hat-linux-server/" target="_blank" rel="noopener">How to Change Hostname of RHEL system?</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15190-there-are-still-remote-logins-for-the-server-dbserver/">Fix Error 15190: There are still remote logins for the server &#8216;DBSERVER&#8217;.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-15190-there-are-still-remote-logins-for-the-server-dbserver/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Find When SQL Server was Installed?</title>
		<link>https://techyaz.com/sql-server/find-when-sql-server-was-installed/</link>
					<comments>https://techyaz.com/sql-server/find-when-sql-server-was-installed/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sun, 08 Apr 2018 09:36:05 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[logins]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2070</guid>

					<description><![CDATA[<p>Have you ever thought when SQL Server instance was installed on your machine? If you don&#8217;t have idea about finding SQL Server installation date then you should keep reading this article where i have described how to know when SQL&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/find-when-sql-server-was-installed/">How to Find When SQL Server was Installed?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Have you ever thought when SQL Server instance was installed on your machine? If you don&#8217;t have idea about finding SQL Server installation date then you should keep reading this article where i have described how to know when SQL Server was installed on your database server?</p>
<p>There are many ways to check SQL Server installation date on your machine. Here i am going to discuss two popular methods that we can use easily to get install date of SQL Server. Let’s go one by one in step by step process.</p>
<h3><span style="color: #333399;">Method 1</span></h3>
<p>As we know whenever we install SQL Server, a SQL Server Agent job named <strong><em>“syspolicy_purge_history”</em></strong> got created. The install date of SQL Server instance will be same as the create date of this job because this job was created during SQL Server installation. So, if you need to find when SQL Server was installed on your database server then you can get it by create date info of above job. Follow below steps to get the details.</p>
<p>You can expand <em>SQL Server Agent</em> folder in SSMS and then <em>Jobs</em> folder. Here you can see this job. We can launch <em>Properties</em> window of job <strong><em>“syspolicy_purge_history”</em></strong> or you can query msdb database to get the details of this job. Here, I have launched Properties windows of this job and we can see the create date of this job is below screenshot. It means this SQL Server Instance was installed on 27<sup>th</sup> July 2017 as showing as create date of below job.</p>
<p><img decoding="async" class="alignnone size-full wp-image-2071" src="http://techyaz.com/wp-content/uploads/2018/04/1_agentjob-min.jpg" alt="Get SQL Server Installation Date" width="705" height="635" srcset="https://techyaz.com/wp-content/uploads/2018/04/1_agentjob-min.jpg 705w, https://techyaz.com/wp-content/uploads/2018/04/1_agentjob-min-300x270.jpg 300w" sizes="(max-width: 705px) 100vw, 705px" /></p>
<h3><span style="color: #333399;">Method 2</span></h3>
<p>Another method to get SQL Server install date on your database server is by using SQL Server system logins. These system logins get created when we install SQL Server. Some of the system logins are <em>NT SERVICE\SQLWriter, NT Service\MSSQLSERVER, NT AUTHORITY\SYSTEM and NT AUTHORITY\NETWORK SERVICE</em>. You can also see some of the system logins that starts with hash <strong>#</strong> like <em>##MS_Policy*****</em> etc. As I said these logins get created during SQL Server installation so to get SQL Server installation date we can check the create date of any such logins.</p>
<p>You can run below commands to check the create date of any of system logins. I have executed below commands to check create date of three system logins.</p>
<pre><span style="color: #0000ff;"><strong>SELECT name, create_date</strong></span>
<span style="color: #0000ff;"><strong>FROM sys.server_principals</strong></span>
<span style="color: #0000ff;"><strong>WHERE name='NT SERVICE\SQLWriter'</strong></span>
<span style="color: #0000ff;"><strong>GO</strong></span>

<span style="color: #0000ff;"><strong>SELECT name, create_date</strong></span>
<span style="color: #0000ff;"><strong>FROM sys.server_principals</strong></span>
<span style="color: #0000ff;"><strong>WHERE name='NT Service\MSSQLSERVER'</strong></span>
<span style="color: #0000ff;"><strong>GO</strong></span>

<span style="color: #0000ff;"><strong>SELECT name, create_date</strong></span>
<span style="color: #0000ff;"><strong>FROM sys.server_principals</strong></span>
<span style="color: #0000ff;"><strong>WHERE name='NT AUTHORITY\SYSTEM'</strong></span>
<span style="color: #0000ff;"><strong>GO</strong></span></pre>
<p>We can see create date of all above SQL Server system logins are same as the create date of system job &#8220;<strong><em>syspolicy_purge_history&#8221; </em></strong>that is described in method 1. So, SQL Server install date on this database server was 27<sup>th</sup> July 2017 as shown in below image.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2072" src="http://techyaz.com/wp-content/uploads/2018/04/2-systemaccounts-min.jpg" alt="Get SQL Server Installation date using system logins" width="577" height="418" srcset="https://techyaz.com/wp-content/uploads/2018/04/2-systemaccounts-min.jpg 559w, https://techyaz.com/wp-content/uploads/2018/04/2-systemaccounts-min-300x217.jpg 300w" sizes="auto, (max-width: 577px) 100vw, 577px" /></p>
<p>You can also get SQL Server install date by getting update date of system account <em><strong>sa</strong></em>. As we have disabled <em><strong>sa</strong> </em>account as part of SQL Server hardening so last update was captured when we disabled this account. But this does not show correct info always because if anybody has enabled this account and again disabled it then this will give you inaccurate information but you can use this information to compare the update date information with the create date of other logins and jobs. This will help you in identifying the install date of SQL Server in more accurate manner.</p>
<pre><strong><span style="color: #0000ff;">SELECT *</span></strong>
<strong><span style="color: #0000ff;">FROM syslogins</span></strong>
<strong><span style="color: #0000ff;">WHERE name='sa'</span></strong>
<strong><span style="color: #0000ff;">GO</span></strong>

<strong><span style="color: #0000ff;">SELECT *</span></strong>
<strong><span style="color: #0000ff;">FROM sys.server_principals</span></strong>
<strong><span style="color: #0000ff;">WHERE name='NT AUTHORITY\SYSTEM'</span></strong>
<strong><span style="color: #0000ff;">GO</span></strong></pre>
<p>You can see the update date of <em><strong>sa</strong></em> account and create date of the another system login shows same date that is also the SQL Server Installation date.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-large wp-image-2073" src="http://techyaz.com/wp-content/uploads/2018/04/3_sa-min-1024x307.jpg" alt="update date of sa account" width="1024" height="307" srcset="https://techyaz.com/wp-content/uploads/2018/04/3_sa-min-1024x307.jpg 1024w, https://techyaz.com/wp-content/uploads/2018/04/3_sa-min-300x90.jpg 300w, https://techyaz.com/wp-content/uploads/2018/04/3_sa-min-768x230.jpg 768w, https://techyaz.com/wp-content/uploads/2018/04/3_sa-min.jpg 1071w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/sql-server-evaluation-period-has-expired-and-how-to-upgrade-it/" target="_blank" rel="noopener">SQL Server Evaluation Period has Expired and How to Upgrade it?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/create-logon-trigger-restrict-sysadmin-logins-connect-sql-server-given-time-interval/" target="_blank" rel="noopener">Create a Logon Trigger to Restrict sysadmin logins to Connect to SQL Server during a given time Interval</a></strong></li>
<li><strong><a href="http://techyaz.com/category/interview-questions/sql-server-interview-questions/">SQL Server Interview Questions &amp; Answers</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/find-when-sql-server-was-installed/">How to Find When SQL Server was Installed?</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/find-when-sql-server-was-installed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix Error 18452: Login failed. The login is from an untrusted domain</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 03 Apr 2018 15:20:47 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[login failed]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2058</guid>

					<description><![CDATA[<p>Recently a user has reported error 18452 while connecting to database server. Full description of this error is given below: Error: 18452, Severity: 14, State: 1. Login failed. The login is from an untrusted domain and cannot be used with&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/">Fix Error 18452: Login failed. The login is from an untrusted domain</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Recently a user has reported error 18452 while connecting to database server. Full description of this error is given below:</p>
<p><span style="color: #ff0000;"><em>Error: 18452, Severity: 14, State: 1.</em></span><br />
<span style="color: #ff0000;"><em>Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.</em></span></p>
<p>You can see the screenshot of the error 18452 in below image.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2068" src="http://techyaz.com/wp-content/uploads/2018/04/1-errormin-1024x152.jpg" alt="error 18452" width="838" height="124" srcset="https://techyaz.com/wp-content/uploads/2018/04/1-errormin-1024x152.jpg 1024w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin-300x45.jpg 300w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin-768x114.jpg 768w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin.jpg 1118w" sizes="auto, (max-width: 838px) 100vw, 838px" /></p>
<h3><span style="color: #333399;">Error 18452 – Root Cause</span></h3>
<p>Reason behind error 18452 is because of wrong security authentication mode configuration. SQL Server is set to accept only windows logins to connect to database instance.</p>
<p>As we know SQL Server uses two authentication modes to accept database connections. One is <em>Windows Authentication mode</em> and another one is <em>SQL Server and Windows Authentication mode</em>. We also call it <em>Mixed Authentication mode</em>.</p>
<p>Sometimes, SQL Server authentication mode is set to <em>SQL Server and Windows Authentication mode</em> to accept SQL as well as windows connections but still you will face this issue. That might be because you try to connect to a server that has <a href="http://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Always on Availability Group</a> configuration or database mirroring configuration.</p>
<p>Suppose you have AOAG configuration and you are connecting to database using primary replica name not listener name using a login for which default database is set as availability database. If failover got happen during your activity or you are connecting to secondary replica using a login for which default database is set as availability database then also you will get this error 18452 along with some SSPI context error that I have given below.</p>
<p><span style="color: #ff0000;"><em>Error: 17806, Severity: 20, State: 14.</em></span><br />
<span style="color: #ff0000;"><em>SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The Windows error code indicates the cause of failure. The logon attempt failed  </em></span></p>
<p>SSPI handshake errors comes because of Kerberos failure, which would most likely be related to non-existent SPN or bad SPN for SQL Server.</p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>To fix this issue first we need to check the authentication mode set for your SQL Server Instance. If your SQL Server instance is running with windows authentication mode then you must change it to Mixed mode so that windows and SQL both type of logins can be authenticated.</p>
<p>To check the configured authentication mode for your SQL Server Instance, we need to launch SQL Server Instance property window. Right click at the instance node and click at the properties option as shown in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2059" src="http://techyaz.com/wp-content/uploads/2018/04/2-error-min.jpg" alt="Launch SQL Server Instance Property Window" width="319" height="525" srcset="https://techyaz.com/wp-content/uploads/2018/04/2-error-min.jpg 319w, https://techyaz.com/wp-content/uploads/2018/04/2-error-min-182x300.jpg 182w" sizes="auto, (max-width: 319px) 100vw, 319px" /></p>
<p>Once you will click at <strong>Properties</strong> option, you will be getting below SQL Server instance property window. Click at <strong>Security</strong> option from left side pane. You can see current <strong>Server Authentication</strong> configuration is set to <strong><em>Windows Authentication mode</em></strong> in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2060" src="http://techyaz.com/wp-content/uploads/2018/04/3-error-min.jpg" alt="SQL Server Instance Property Window" width="638" height="573" srcset="https://techyaz.com/wp-content/uploads/2018/04/3-error-min.jpg 703w, https://techyaz.com/wp-content/uploads/2018/04/3-error-min-300x269.jpg 300w" sizes="auto, (max-width: 638px) 100vw, 638px" /></p>
<p>Now we will change it to <strong><em>SQL Server and Windows Authentication mode</em></strong>. Select the radio button for <em>SQL Server and Windows Authentication mode</em> option and click ok button to proceed. You can see that I have selected above mode to apply the changes.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2061" src="http://techyaz.com/wp-content/uploads/2018/04/4-error-min.jpg" alt="SQL Server Instance Property Window" width="638" height="578" srcset="https://techyaz.com/wp-content/uploads/2018/04/4-error-min.jpg 702w, https://techyaz.com/wp-content/uploads/2018/04/4-error-min-300x272.jpg 300w" sizes="auto, (max-width: 638px) 100vw, 638px" /></p>
<p>Restart SQL Server services to apply the changes.</p>
<p>If your SQL Server Instance is already set with <em>SQL Server and Windows Authentication mode</em> then you should fix this issue in separate way. As I described above that one of the probable reason to get this error 18452 is because you might use AOAG replica server name to connect to the database with the login for which default database is set as the AOAG availability database.</p>
<p>If failover will happen then you would not be able to access the database because it will become secondary. Error 18452 will be generated along with SSPI handshake errors because same database is set as default database for your login that has become inaccessible now because of acting secondary database in AOAG. Failover will not happen for you because you are using replica server name to make database connection.</p>
<p>Possible solution to fix this issue is failback the AOAG to your earlier primary replica or you should use AOAG Listener name to make database connection. Also, to avoid this error during failover you should set default database for your login to master rather than availability database.</p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><em><strong><span style="color: #800000;">Read More:</span></strong></em></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/" target="_blank" rel="noopener">Fix Error 18456: Login failed for user &#8220;User_Name&#8221;</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/" target="_blank" rel="noopener">Fix Error 4064: Cannot open user default database. Login failed</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-53-not-open-connection-sql-server/" target="_blank" rel="noopener">Error 53: Could not open a connection on SQL Server</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">AOAG Listener Error 19471: The handle is Invalid</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/">Fix Error 18452: Login failed. The login is from an untrusted domain</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 4064: Cannot open user default database. Login failed.</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 06 Dec 2017 07:12:27 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[login failed]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1285</guid>

					<description><![CDATA[<p>Today, I got Microsoft SQL Server error 4064 while I was trying to connect to my SQL Server Instance using my login id techyaz. Read this article to fix this SQL Server error 4064. The error text of this error&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/">Fix SQL Server Error 4064: Cannot open user default database. Login failed.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today, I got Microsoft SQL Server error 4064 while I was trying to connect to my SQL Server Instance using my login id techyaz. Read this article to fix this SQL Server error 4064. The error text of this error is &#8220;<em>Cannot open user default database. Login failed.&#8221;</em> This solution is apply to both SQL logins as well as windows logins. The error details are given below:</p>
<div><em><span style="color: #ff0000;">Cannot open user default database. Login failed.</span></em><br />
<em><span style="color: #ff0000;"> Login failed for user “techyaz”. (Microsoft SQL Server, Error: 4064)</span></em></div>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/" target="_blank" rel="noopener">Fix 15170: Logins owns one or more Agent Jobs</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">How to fix error 15434: Could not drop login as the user is currently logged in</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Error Code 15174: Login &#8216;xxx\yyy&#8217; Owns one or more databases(s). Change the owner of database(s) before dropping the login.</a></strong></li>
</ul>
<h3><span style="color: #333399;">Microsoft SQL Server Error 4064</span></h3>
<p>SQL Server Error 4064 generates because the default database set for your login has been dropped or becomes inaccessible by any reason. Whenever we create any SQL Server or windows login, we mention a default database. If you don’t mention any database during login creation then SQL Server set default database as master database.</p>
<p>You might also get this error on secondary replica of <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysON Availability Group</a> because that database on secondary replica remains into inaccessible mode. So, don&#8217;t do any changes if you are getting this error in AOAG environment. You just need to connect to the primary replica because it is designed to keep secondary replica database into inaccessible mode.</p>
<p>Here, we had a database named “TechyazDB” that was set as default database for my login <strong>techyaz</strong>. This database was dropped by someone and when I tried to connect to SQL Server, it gave me below Microsoft SQL Server error 4064 because database was not there on SQL Server instance. Below is the screenshot of Microsoft SQL Server error 4064 that is clearly saying &#8220;<em>Cannot open user default database. Login failed.&#8221;</em></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1287 size-full" src="http://techyaz.com/wp-content/uploads/2017/12/1-error-4064-min.jpg" alt="error 4064" width="633" height="347" srcset="https://techyaz.com/wp-content/uploads/2017/12/1-error-4064-min.jpg 633w, https://techyaz.com/wp-content/uploads/2017/12/1-error-4064-min-300x164.jpg 300w" sizes="auto, (max-width: 633px) 100vw, 633px" /></p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>There are two solutions to fix this issue. Either make your database online by restoring it or by anyway or change the default database of this login to master or any other database that is online on the instance. As you cannot bring your database online because you can’t connect to the instance so your first option is to connect to the instance.</p>
<p>If you have other DBAs or sysadmin accounts, you can connect using those accounts to SQL Server and change the default database for your login to master and then you can make database connection.</p>
<p>Let’s consider only you are the admin on this instance so how will you fix it. Follow below steps:</p>
<p>Launch <strong>SSMS</strong> and click on connect to database engine. Enter <strong>server name</strong> and <strong>login details</strong> for which you are facing issue.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1288" src="http://techyaz.com/wp-content/uploads/2017/12/2-connect-using-techyaz-min.jpg" alt="connect to database engine" width="442" height="334" srcset="https://techyaz.com/wp-content/uploads/2017/12/2-connect-using-techyaz-min.jpg 442w, https://techyaz.com/wp-content/uploads/2017/12/2-connect-using-techyaz-min-300x227.jpg 300w" sizes="auto, (max-width: 442px) 100vw, 442px" /></p>
<p>Now click on <strong>Options</strong> tab of above image. You will get below screenshot.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1289" src="http://techyaz.com/wp-content/uploads/2017/12/3-connect-using-techyaz-options-tab-min.jpg" alt="click on options tab of connect database window" width="434" height="515" srcset="https://techyaz.com/wp-content/uploads/2017/12/3-connect-using-techyaz-options-tab-min.jpg 434w, https://techyaz.com/wp-content/uploads/2017/12/3-connect-using-techyaz-options-tab-min-253x300.jpg 253w" sizes="auto, (max-width: 434px) 100vw, 434px" /></p>
<p>You can see <strong>Connect to Database</strong> option is set to default database that was <strong>TechyazDB</strong> for this login. Now we need to change this default to any accessible database. It will not allow you to select from drop down. If you will browse the database it will give you same error. You need to enter or type the database name. I typed as master database as shown in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1290" src="http://techyaz.com/wp-content/uploads/2017/12/4-change-database-to-master-min.jpg" alt="change default database in connection property" width="440" height="512" srcset="https://techyaz.com/wp-content/uploads/2017/12/4-change-database-to-master-min.jpg 440w, https://techyaz.com/wp-content/uploads/2017/12/4-change-database-to-master-min-258x300.jpg 258w" sizes="auto, (max-width: 440px) 100vw, 440px" /></p>
<p>Now click on <strong>connect</strong> button to establish the database connection. This time you can connect to your SQL Server instance.</p>
<p>Now, it’s your wish whether you want to bring your database online first or you want to change the default database of your login. Generally, if database has been dropped as a planned activity then you need to change the default database of your login. Read below section to know how to change default database of your login.</p>
<h5><span style="color: #333399;"><strong>Change default database of Login Name</strong></span></h5>
<p>There are two options to change the default database set to any login. One is by using T-SQL code and another is by using GUI. Let’s start with <strong>GUI method</strong>.</p>
<p>As you have connected to your SQL Server Instance. Expand <strong>Security</strong> Folder followed by <strong>Logins</strong> folder. Now <strong>double click</strong> on your login name or right click on login and choose <strong>properties</strong> tab. You will get below property window.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1291" src="http://techyaz.com/wp-content/uploads/2017/12/5-change-default-database-to-master-min.jpg" alt="login property" width="709" height="631" srcset="https://techyaz.com/wp-content/uploads/2017/12/5-change-default-database-to-master-min.jpg 709w, https://techyaz.com/wp-content/uploads/2017/12/5-change-default-database-to-master-min-300x267.jpg 300w" sizes="auto, (max-width: 709px) 100vw, 709px" /></p>
<p>You can see <strong>default database is showing as blank</strong>. This was the main issue because your database has dropped from the instance. Now change it to <strong>master</strong> database and click on <strong>OK</strong> button to proceed.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1293" src="http://techyaz.com/wp-content/uploads/2017/12/6-change-default-database-to-master-in-login-techyaz-min.jpg" alt="change default database in login property window" width="703" height="631" srcset="https://techyaz.com/wp-content/uploads/2017/12/6-change-default-database-to-master-in-login-techyaz-min.jpg 703w, https://techyaz.com/wp-content/uploads/2017/12/6-change-default-database-to-master-in-login-techyaz-min-300x269.jpg 300w" sizes="auto, (max-width: 703px) 100vw, 703px" /></p>
<p><strong>Second method</strong> is T-SQL method. Run below ALTER command to set the default database of your login.</p>
<pre><span style="color: #0000ff;"><strong><span style="color: #008000;">--Change techyaz with your login name.</span>
ALTER LOGIN [techyaz] WITH DEFAULT_DATABASE = master
</strong></span></pre>
<p>Below is the screenshot of this command.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1294 size-full" src="http://techyaz.com/wp-content/uploads/2017/12/7-change-default-database-to-master-in-login-techyaz-t-sql-min.jpg" alt="T-SQL code to set the default database for a login" width="454" height="143" srcset="https://techyaz.com/wp-content/uploads/2017/12/7-change-default-database-to-master-in-login-techyaz-t-sql-min.jpg 454w, https://techyaz.com/wp-content/uploads/2017/12/7-change-default-database-to-master-in-login-techyaz-t-sql-min-300x94.jpg 300w" sizes="auto, (max-width: 454px) 100vw, 454px" /></p>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">Fix Error 15173: Revoke the permission(s) before dropping the login</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The Server Principal owns one or more endpoints.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 and Error 3729</a></strong></li>
</ul>
<p>Here, I have explained step by step solution to fix <em>SQL Server error 4064: Cannot open user default database.</em> I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/">Fix SQL Server Error 4064: Cannot open user default database. Login failed.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</title>
		<link>https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 09 Oct 2017 14:52:27 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[AOAG Listener]]></category>
		<category><![CDATA[endpoints]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[Listener Issue]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1048</guid>

					<description><![CDATA[<p>We got this Microsoft SQL Server error 35250 while configuring Alwayson Availability Group on one of the SQL Server Instance. There could be multiple reasons behind this SQL error 35250. You can find multiple solutions to fix this issue based&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/">SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We got this Microsoft SQL Server error 35250 while configuring <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Alwayson Availability Group</a> on one of the SQL Server Instance. There could be multiple reasons behind this SQL error 35250. You can find multiple solutions to fix this issue based on the nature of the issue. Here I will show you, how to fix this Alwayson error 35250 that came due to SQL Server service accounts.</p>
<h3><span style="color: #000080;">Microsoft SQL Server Error 35250</span></h3>
<p>We generally get this error whenever there is a communication issue between endpoints of both replicas or any replica unable to connect to the endpoints cause this error to generate. You will see below error texts if you are getting this issue.</p>
<p><span style="color: #ff0000;"><em>Alwayson Error 35250</em></span><br />
<span style="color: #ff0000;"><em>Failed to Join the database &#8216;DBName&#8217; to the availability group &#8216;AOAG-Name&#8217; on the availability replica &#8216;Availability Replica Name&#8217;</em></span></p>
<p>There are many reasons behind this error that we will discuss in next section. You might also get below text if you are using T-SQL.</p>
<div><span style="color: #ff0000;"><em>Msg 35250, Level 16, State 7, Line 1</em></span><br />
<span style="color: #ff0000;"><em> The connection to the primary replica is not active.  The command cannot be processed. (microsoft sql server, error: 35250)</em></span></div>
<p>Below is the screenshot of this error.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1049" src="http://techyaz.com/wp-content/uploads/2017/10/1-Error-AOAG.jpg" alt="Error 35250" width="669" height="399" srcset="https://techyaz.com/wp-content/uploads/2017/10/1-Error-AOAG.jpg 669w, https://techyaz.com/wp-content/uploads/2017/10/1-Error-AOAG-300x179.jpg 300w" sizes="auto, (max-width: 669px) 100vw, 669px" /></p>
<h3><span style="color: #000080;">Solution</span></h3>
<p>You should check below points based on attached article <a href="https://blogs.msdn.microsoft.com/alwaysonpro/2013/12/09/create-availability-group-fails-with-error-35250-failed-to-join-the-database/">MSDN link</a> whenever you get this error.</p>
<ul>
<li>Inbound Port 5022 Traffic is Blocked</li>
<li>Endpoint is not created or started</li>
<li>Endpoint permissions</li>
<li>SQL Server is not listening on port 5022</li>
</ul>
<p>But if everything is ok and you are still not able to diagnose this issue, then you should keep reading this article.</p>
<p>I checked everything and all was well on both replicas.  As we know that there should be Grant CONNECT permission on Always On endpoint. I was reassigning GRANT CONNECT on the endpoint and came to know that the SQL Server service account was not added to the SQL Server instance of secondary replica. That is why we faced this error. Let’s first get the endpoint and then we will run Grant connect on endpoint to see the issue. Run below command to get the name of endpoint that is using in this alwayson configuration.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1050" src="http://techyaz.com/wp-content/uploads/2017/10/2-Get-the-endpoint-name.jpg" alt="get endpoint name" width="775" height="227" srcset="https://techyaz.com/wp-content/uploads/2017/10/2-Get-the-endpoint-name.jpg 775w, https://techyaz.com/wp-content/uploads/2017/10/2-Get-the-endpoint-name-300x88.jpg 300w, https://techyaz.com/wp-content/uploads/2017/10/2-Get-the-endpoint-name-768x225.jpg 768w" sizes="auto, (max-width: 775px) 100vw, 775px" /></p>
<p>We can see endpoint name is <strong>hadr_endpoint</strong>. Now run below command to grant connect permission on endpoint hadr_endpoint. The login name is the service account that is used to run SQL Server services.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1051" src="http://techyaz.com/wp-content/uploads/2017/10/3-Run-cmd-togrant-connect.jpg" alt="grant connect on endpoint" width="751" height="179" srcset="https://techyaz.com/wp-content/uploads/2017/10/3-Run-cmd-togrant-connect.jpg 751w, https://techyaz.com/wp-content/uploads/2017/10/3-Run-cmd-togrant-connect-300x72.jpg 300w" sizes="auto, (max-width: 751px) 100vw, 751px" /></p>
<p>You can see, error is saying that the account doesn’t exist on SQL Server.</p>
<p>Although you can directly check this step in SSMS as a prerequisite once error is reported. The SQL Server service accounts should be added to SQL Server Instances. I checked this account on both replica and found that it was very much there on primary replica but it was not created on secondary replica. That was the missing point which caused this issue.</p>
<p>Now create this service account on secondary replica as well or where it was missing on any of the replica then you can try to re-add the database to the AOAG configuration. This time your database will be added to the AOAG configuration. If you are facing issue during joining database to the AOAG configuration then you can remove the existing AOAG and reconfigure it.</p>
<p>Your issue will be fixed if you check and follow all above suggested points including the one mentioned in MSDN link. I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p><em><span style="color: #800000;"><strong>Read More:</strong></span></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-976/" target="_blank" rel="noopener">Fix AOAG Error 976:Cannot Connect to Secondary Replica</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">How to fix AOAG Listener Issue 19471: The handle is Invalid</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/" target="_blank" rel="noopener">Fix Listener Issue that came during AOAG Configuration</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix Error 15141: The Server Principal owns one or more endpoints</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">Fixing Application connectivity Issue after AOAG automatic failover</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/">SQL Server Alwayson Error 35250: Joining database on Secondary Replica resulted in an error</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fix-alwayson-error-35250-joining-database-secondary-replica-resulted-error/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 976: Cannot connect to Secondary Replica of AlwaysON Availability Group</title>
		<link>https://techyaz.com/sql-server/alwayson/fix-error-976/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fix-error-976/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 13 Sep 2017 10:00:51 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[Database Mirroring]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[Connection Issue]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=883</guid>

					<description><![CDATA[<p>Today an application user has reported that he is not able to connect to the secondary replica of AlwaysOn Availability Group configuration. The details about error Microsoft SQL Server 976 that he was getting is given below. Cannot connect to&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-976/">Fix SQL Server Error 976: Cannot connect to Secondary Replica of AlwaysON Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today an application user has reported that he is not able to connect to the secondary replica of <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability Group</a> configuration. The details about error Microsoft SQL Server 976 that he was getting is given below.</p>
<p><span style="color: #ff0000;"><strong><em>Cannot connect to &#8216;Secondary Replica Server&#8217;.<br />
ADDITIONAL INFORMATION:<br />
</em></strong><em>The target database, &#8216;SDGC&#8217;, is participating in an availability group and is currently not accessible for queries. Either data movement is suspended or the availability replica is not enabled for read access. To allow read-only access to this and other databases in the availability group, enable read access to one or more secondary availability replicas in the group.  For more information, see the ALTER AVAILABILITY GROUP statement in SQL Server Books Online. (Microsoft SQL Server, Error: 976)</em></span></p>
<p>The screenshot of this error is given below.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-884" src="http://techyaz.com/wp-content/uploads/2017/09/1-Error-976.jpg" alt="Error 976" width="614" height="326" srcset="https://techyaz.com/wp-content/uploads/2017/09/1-Error-976.jpg 614w, https://techyaz.com/wp-content/uploads/2017/09/1-Error-976-300x159.jpg 300w" sizes="auto, (max-width: 614px) 100vw, 614px" /></p>
<h3><span style="color: #000080;">Solution</span></h3>
<p>Before going ahead let me give you a background about SQL Server configurations.</p>
<ul>
<li>We have <strong>two SQL Servers Server A &amp; Server B</strong> and there is an user database <strong>SDGC</strong> is hosted on both SQL Server Instances.</li>
<li><strong>AOAG</strong> is configured between both servers in <strong>Automatic failover</strong> mode for database <strong>SDGC</strong>.</li>
<li>Availability database <strong>SDGC </strong>hosted on instance B is <strong>inaccessible</strong> because it was restored in <strong>no recovery mode</strong> and not set in read only mode for AOAG configuration.</li>
<li>User&#8217;s login was created on both SQL Server instances with having default database as <strong>SDGC</strong> that are participating in AOAG.</li>
</ul>
<p>Now, the problem is whenever user tries to connect to the secondary replica whether AOAG is active from instance A or instance B, he is not able to connect to the SQL Server Instance and getting given SQL Server error 976. I analyzed this issue and found two solutions to fix this issue:</p>
<ul>
<li>Change <strong>Connect to database</strong> value in SSMS while establishing the connection.</li>
<li>Change <strong>default database </strong>value of your Login in Login Property window.</li>
</ul>
<p><span style="color: #800000;"><strong>Change Connect to database value in SSMS</strong></span></p>
<p>Launch <strong>SQL Server Management Studio</strong>. Click on <strong>Options</strong> tab of connection details window in SSMS as shown in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-885" src="http://techyaz.com/wp-content/uploads/2017/09/2-connect-using-different-user-Copy.jpg" alt="click on connect button in SSMS" width="397" height="290" srcset="https://techyaz.com/wp-content/uploads/2017/09/2-connect-using-different-user-Copy.jpg 397w, https://techyaz.com/wp-content/uploads/2017/09/2-connect-using-different-user-Copy-300x219.jpg 300w" sizes="auto, (max-width: 397px) 100vw, 397px" /></p>
<p>You can see, <strong>Connect to database</strong> value showing as <strong>default</strong> that means it is connecting to the database that is set as <strong>default database</strong> for user&#8217;s login. Remember, <strong>default database</strong> for user&#8217;s login is set as <strong>SDGC</strong> that is running in <strong>norecovery mode</strong>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-886" src="http://techyaz.com/wp-content/uploads/2017/09/3.0-connect-default-db.jpg" alt="connect to database in ssms" width="374" height="436" srcset="https://techyaz.com/wp-content/uploads/2017/09/3.0-connect-default-db.jpg 374w, https://techyaz.com/wp-content/uploads/2017/09/3.0-connect-default-db-257x300.jpg 257w" sizes="auto, (max-width: 374px) 100vw, 374px" /></p>
<p>Now, we just need to change the <strong>connect to database</strong> value from <strong>default</strong> to <strong>master</strong> or some other database. As <strong>default database</strong> for user&#8217;s login was set to SDGC, so change it master to make database engine to read an accessible database.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-887" src="http://techyaz.com/wp-content/uploads/2017/09/3.5-Change-default-db.jpg" alt="Change connect to database to master in ssms" width="374" height="436" srcset="https://techyaz.com/wp-content/uploads/2017/09/3.5-Change-default-db.jpg 374w, https://techyaz.com/wp-content/uploads/2017/09/3.5-Change-default-db-257x300.jpg 257w" sizes="auto, (max-width: 374px) 100vw, 374px" /></p>
<p>Once you make changes, hit the connect button and establish a database connection. This time you will be able to establish database connection to secondary replica.</p>
<p><span style="color: #800000;"><strong>Change default database value of your Login</strong></span></p>
<p>If <strong>default database</strong> of your login is <strong>not mandatory</strong> to set to <strong>availability database</strong> then you can change it to master and remove this issue permanently. Otherwise, you need to change default database every time you make a connection to secondary replica as discussed in above section.<br />
You can connect to your <strong>secondary replica</strong> or to the server where you are facing this issue using <strong>different admin or security admin account</strong>. If you have such account and password, you don&#8217;t need to logoff and relogin. You can just <strong>right click on SSMS icon</strong> while <strong>pressing SHIFT button</strong> to logged in using different user to the SQL Server instance. You can see that option in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-888" src="http://techyaz.com/wp-content/uploads/2017/09/4-connect-using-different-user.jpg" alt="login using different account" width="451" height="355" srcset="https://techyaz.com/wp-content/uploads/2017/09/4-connect-using-different-user.jpg 451w, https://techyaz.com/wp-content/uploads/2017/09/4-connect-using-different-user-300x236.jpg 300w" sizes="auto, (max-width: 451px) 100vw, 451px" /></p>
<p>Click on &#8220;<strong>Run as different user</strong>&#8221; option. It will display below login screen to enter your new login and password. Enter the credentials.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-889" src="http://techyaz.com/wp-content/uploads/2017/09/5-connect-different-user.jpg" alt="Enter Credentials" width="382" height="329" srcset="https://techyaz.com/wp-content/uploads/2017/09/5-connect-different-user.jpg 382w, https://techyaz.com/wp-content/uploads/2017/09/5-connect-different-user-300x258.jpg 300w" sizes="auto, (max-width: 382px) 100vw, 382px" /></p>
<p>Once your new account will be authenticated, SSMS will be launched and show you the details as shown in below image. Click on <strong>Connect</strong> button to establish the connection.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-890" src="http://techyaz.com/wp-content/uploads/2017/09/6-connect-using-different-user.jpg" alt="connect using different account in ssms" width="397" height="290" srcset="https://techyaz.com/wp-content/uploads/2017/09/6-connect-using-different-user.jpg 397w, https://techyaz.com/wp-content/uploads/2017/09/6-connect-using-different-user-300x219.jpg 300w" sizes="auto, (max-width: 397px) 100vw, 397px" /></p>
<p>Expand <strong>Security</strong> folder. <strong>Identify</strong> your login for which you have to change the default database setting. <strong>Right click</strong> and choose <strong>properties</strong> on this login to launch properties window. You can <strong>double click</strong> on this login as well to launch this properties window. Below window will come to your screen where you can see the default database set for this login.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-891" src="http://techyaz.com/wp-content/uploads/2017/09/7-login.jpg" alt="login property" width="625" height="559" srcset="https://techyaz.com/wp-content/uploads/2017/09/7-login.jpg 625w, https://techyaz.com/wp-content/uploads/2017/09/7-login-300x268.jpg 300w" sizes="auto, (max-width: 625px) 100vw, 625px" /></p>
<p>You can see <strong>default database</strong> is set as <strong>SDGC</strong> in above screenshot. Now we need to <strong>change</strong> it to <strong>master</strong> or any accessible database. Do the changes, you can see i have changed it to master in our screenshot. Once you make changes, click on <strong>Ok</strong> button to proceed.</p>
<p><strong>NOTE:</strong> <em>If you need to change default database back to availability database due to some application dependencies then you need to first make your availability database accessible. You can perform failover to make secondary replica as primary then you can make changes and then you can failback. If you don&#8217;t want to perform failover/failback, then you can do this by changing the availability database from norecovery to read only mode.</em></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-892" src="http://techyaz.com/wp-content/uploads/2017/09/8-login.jpg" alt="login property" width="621" height="547" srcset="https://techyaz.com/wp-content/uploads/2017/09/8-login.jpg 621w, https://techyaz.com/wp-content/uploads/2017/09/8-login-300x264.jpg 300w" sizes="auto, (max-width: 621px) 100vw, 621px" /></p>
<p>Now your <strong>issue is fixed. </strong>You would be able to connect to the SQL Server Instance that are running as secondary replica in AOAG configuration.  You can see, i have connected to secondary replica using same account with whom i was facing issue.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-893" src="http://techyaz.com/wp-content/uploads/2017/09/9-connect-using-samelogin.jpg" alt="" width="419" height="452" srcset="https://techyaz.com/wp-content/uploads/2017/09/9-connect-using-samelogin.jpg 419w, https://techyaz.com/wp-content/uploads/2017/09/9-connect-using-samelogin-278x300.jpg 278w" sizes="auto, (max-width: 419px) 100vw, 419px" /></p>
<p><span style="color: #800000;"><em><strong>Related Articles:</strong></em></span></p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-19471-listener-issue-that-came-during-configuring-sql-server-alwayson-availability-group/" target="_blank" rel="noopener">Fix Error 19471: Listener Issue during Configuring AOAG</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">How to Fix SAP connectivity issue after AOAG failover</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">Fix: Secondary Replica is showing in Resolving state</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">Fix SQL Server Error 15141: Server Principal owns one or more endpoints</a></strong></li>
</ul>
</li>
</ul>
<p>Please comment us to give your feedback. I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-976/">Fix SQL Server Error 976: Cannot connect to Secondary Replica of AlwaysON Availability Group</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fix-error-976/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fixing Error &#8220;User is not in the sudoers file. This incident will be reported.&#8221;</title>
		<link>https://techyaz.com/rhel/fixing-error-user-not-sudoers-file-incident-will-reported-red-hat-linux-server/</link>
					<comments>https://techyaz.com/rhel/fixing-error-user-not-sudoers-file-incident-will-reported-red-hat-linux-server/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 31 Aug 2017 09:11:51 +0000</pubDate>
				<category><![CDATA[RedHat Linux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[red hat Linux]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[sudoers file]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wheel group]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=712</guid>

					<description><![CDATA[<p>I got this error during one of the activity when i was not able to perform it because my user was not part of sudoers file.  The error details were given as &#8220;User is not in the sudoers file. This&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/rhel/fixing-error-user-not-sudoers-file-incident-will-reported-red-hat-linux-server/">Fixing Error &#8220;User is not in the sudoers file. This incident will be reported.&#8221;</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got this error during one of the activity when i was not able to perform it because my user was not part of sudoers file.  The error details were given as &#8220;<em>User is not in the sudoers file. This incident will be reported.</em>&#8221; If a user is not part of sudoers file then that user cannot perform anything using sudo command. Here i will explain how to fix this error or in other words you can say how to add a Linux user into sudoers file.</p>
<h3><span style="color: #000080;"><strong>Linux Error: User is not in the sudoers file. This incident will be reported.</strong></span></h3>
<p>Sudoers file determines which users can run administrative tasks, those requiring superuser privileges. I was failed to perform certain tasks because my username was not part of this file and returned with below error.</p>
<p><span class="kwrd" style="color: red;"><em>Linux Error: User is not in the sudoers file. This incident will be reported.</em><br />
</span></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-713" src="http://techyaz.com/wp-content/uploads/2017/08/1-1.jpg" alt="user name not in sudoers file" width="739" height="67" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-1.jpg 739w, https://techyaz.com/wp-content/uploads/2017/08/1-1-300x27.jpg 300w" sizes="auto, (max-width: 739px) 100vw, 739px" /></p>
<p>Someone who has super user (su) access can fix this issue by adding the impacted user to the <strong>Wheel group</strong>. The <strong>wheel group</strong> is a special user group used on Linux systems to control access to the sudo command, which allows a user to behave as super user. Once we will add our user into this group, we will be able to use sudo command.</p>
<h3><span style="color: #000080;"><strong>Adding a Linux User to Sudoers File</strong></span></h3>
<p>Connect to your Linux server using superuser account.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">#Connect using su</span>
su
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-714" src="http://techyaz.com/wp-content/uploads/2017/08/2-login-using-su.jpg" alt="login using su account" width="461" height="64" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-login-using-su.jpg 461w, https://techyaz.com/wp-content/uploads/2017/08/2-login-using-su-300x42.jpg 300w" sizes="auto, (max-width: 461px) 100vw, 461px" /></p>
<p>We have now connected to Linux server using superuser account. Now we can add our username to the Wheel group.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">#Add your user to the Wheel group. 
#Change techyaz to your user name</span>.
usermod -G wheel techyaz
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-715" src="http://techyaz.com/wp-content/uploads/2017/08/3-add-wheel-group.jpg" alt="Add Username to wheel group" width="670" height="90" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-add-wheel-group.jpg 670w, https://techyaz.com/wp-content/uploads/2017/08/3-add-wheel-group-300x40.jpg 300w" sizes="auto, (max-width: 670px) 100vw, 670px" /></p>
<p>Now we see that command executed successfully. If you attempt to execute the sudo command now, you might get the same error message unless you completely logout your user and re-login again. Next you can exit from superuser account by typing exit on the prompt.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;"><span style="color: #008000;">#Exit su account</span>
exit
</span></strong></pre>
<p>Your account or user added to sudoers file now by adding it to wheel group. You can now connect to Linux server from your PuTTY terminal or on the local server and try to run sudo command post completely logout your user and re-login on the server.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong><span style="color: #008000;">#Connect to Linux server using your user name that was added to wheel group.
#Run sudo su</span></strong>
<strong>sudo su
</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-716" src="http://techyaz.com/wp-content/uploads/2017/08/4-validate.jpg" alt="validate the change" width="840" height="198" srcset="https://techyaz.com/wp-content/uploads/2017/08/4-validate.jpg 840w, https://techyaz.com/wp-content/uploads/2017/08/4-validate-300x71.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/4-validate-768x181.jpg 768w" sizes="auto, (max-width: 840px) 100vw, 840px" /></p>
<p>You can see we have access to run anything using sudo command in above screenshot. Now your username is part of sudoers file so you can perform your activities using sudo command now.</p>
<p><em><span style="color: #800000;"><strong>Read more:</strong></span></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/sql-server-on-linux/step-step-process-install-red-hat-enterprise-linux/" target="_blank" rel="noopener">How to Install Red Hat Linux 7.3 on Virtual Machine</a></strong></li>
<li><strong><a href="https://techyaz.com/rhel/fix-putty-network-error-connection-timed/" target="_blank" rel="noopener">Fixing PuTTY connection issue while connecting to Red Hat Linux Server</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/sql-server-on-linux/install-sql-server-2017-redhat-linux-without-internet-offline-installation/" target="_blank" rel="noopener">Installing SQL Server 2017 on Red Hat Linux Server</a></strong></li>
</ul>
<p>Here, we have fixed Linux error &#8220;<em>User is not in the sudoers file. This incident will be reported</em>.&#8221; I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook</a> page and on <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/rhel/fixing-error-user-not-sudoers-file-incident-will-reported-red-hat-linux-server/">Fixing Error &#8220;User is not in the sudoers file. This incident will be reported.&#8221;</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/rhel/fixing-error-user-not-sudoers-file-incident-will-reported-red-hat-linux-server/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15433, Level 16, State 1: Supplied parameter sid is in use</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 21 Aug 2017 20:00:40 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=572</guid>

					<description><![CDATA[<p>I got Microsoft SQL Server error 15433 during fixing orphaned users on a SQL Server Instance where AlwaysON Availability Group was configured. Our application was facing connectivity issue post AOAG failover and not able to connect to database whereas everything&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/">Fix SQL Server Error 15433, Level 16, State 1: Supplied parameter sid is in use</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got Microsoft SQL Server error 15433 during fixing orphaned users on a SQL Server Instance where <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysON Availability Group</a> was configured. Our application was facing <a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">connectivity issue post AOAG failover</a> and not able to connect to database whereas everything was working fine from database end. Databases were successfully <a href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">transitioning their roles during failover</a>.</p>
<h3><span style="color: #000080;"><strong>Microsoft SQL Server Error 15433, Level 16, State 1: Supplied parameter sid is in use</strong></span></h3>
<p>I have an AOAG configuration having two replicas in my environment which is set for Automatic failover. Last week, we had High Availability testing for all applications. Issue occurred when application team tried to connect to database server after failover. They were <a href="https://techyaz.com/sql-server/troubleshooting/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener">failed to connect to the secondary replica</a> using Listener after failover whereas applications were working fine from primary replica. Issue came because SQL login which was used by application has different sid on secondary replica than the primary replica.</p>
<p>During fixing above issue, we came across an error about which we will be discussing in this post. One of the engineer has accidently created a wrong login with the same SID that we were about to use to create the application login to fix above issue. When we have tried to create application login we get below error.</p>
<div class="codediv"><span class="kwrd" style="color: red;">Msg 15433, level 16, State 1, Line 1,</span></div>
<div class="codediv"><span class="kwrd" style="color: red;">Supplied parameter sid is in use.</span></div>
<p>Here i will explain step by step method to fix this SQL Server Error 15433.</p>
<h3><span style="color: #000080;"><strong>Solution</strong></span></h3>
<p>Here i will reproduce this issue and then fix it in a step by step manner. So, final objective is to create a login with same name, password &amp; sid on secondary replica to sync the login details of associated application. Let us first check the login sid of identified login on primary replica. Run below code to get it.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>SELECT name, SID, createdate from syslogins
WHERE name='xyz'</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-573" src="http://techyaz.com/wp-content/uploads/2017/08/1.jpg" alt="" width="601" height="164" srcset="https://techyaz.com/wp-content/uploads/2017/08/1.jpg 601w, https://techyaz.com/wp-content/uploads/2017/08/1-300x82.jpg 300w" sizes="auto, (max-width: 601px) 100vw, 601px" /></p>
<p>Copy the SID of this login from above screen for further uses. Now connect to secondary replica and run below command to create same login with same password &amp; sid. You can remove Check_Policy option if your login has password policy applied.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>CREATE Login xyz WITH password = 'techy@z@123', Check_Policy=off, SID = 0x03981anjkhdvehh73964jbdbj783</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-574" src="http://techyaz.com/wp-content/uploads/2017/08/2.jpg" alt="" width="514" height="96" srcset="https://techyaz.com/wp-content/uploads/2017/08/2.jpg 514w, https://techyaz.com/wp-content/uploads/2017/08/2-300x56.jpg 300w" sizes="auto, (max-width: 514px) 100vw, 514px" /></p>
<p>Here we got the issue because someone has already created another login with same SID. Now our next step is to check that login which was created with this SID. Run below command on secondary replica to get this done.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>SELECT name, SID, createdate from sysloginswhere SID = 0x0398manjkhdvehh73964jbdbj783</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-575" src="http://techyaz.com/wp-content/uploads/2017/08/3.jpg" alt="" width="519" height="114" srcset="https://techyaz.com/wp-content/uploads/2017/08/3.jpg 519w, https://techyaz.com/wp-content/uploads/2017/08/3-300x66.jpg 300w" sizes="auto, (max-width: 519px) 100vw, 519px" /></p>
<p>We can see the login name which was created under given SID. We have to created application login with same SID to establish application connectivity to database after failover so we will drop this Login and recreate application login with this SID. Later we can create deleted login which will have different SID. If not needed you should not create unwanted logins on SQL Server. Run below command to drop this login.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: green;"><strong>--Change login name with login.</strong></span><strong><span class="kwrd" style="color: blue;">
DROP Login login</span></strong></pre>
<p>SSMS way to drop a login is given in below steps:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-576" src="http://techyaz.com/wp-content/uploads/2017/08/4.jpg" alt="" width="446" height="121" srcset="https://techyaz.com/wp-content/uploads/2017/08/4.jpg 446w, https://techyaz.com/wp-content/uploads/2017/08/4-300x81.jpg 300w" sizes="auto, (max-width: 446px) 100vw, 446px" /></p>
<p>You might get multiple dependency errors during dropping this login because there is possibility this login might own few objects, agent jobs or databases on this instance if it was created long before. You can read below articles to fix such kind of issues if you will face any.</p>
<ul>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix  Error 15173: Revoke the permissions before dropping the login.</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">Fixing error 15138 &amp; Error 3729: DROP login failed</a></li>
<li><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">Error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/" target="_blank" rel="noopener">How to fix error 15170: Login owns one or more SQL Agent Jobs.</a></li>
</ul>
<p>Now once this login will be dropped, you will be able to create your application login with required SID. You can see that in below screen.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>CREATE Login xyz WITH password = 'techy@z@123', Check_Policy=off, SID = 0x03981anjkhdvehh73964jbdbj783</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-577" src="http://techyaz.com/wp-content/uploads/2017/08/5.jpg" alt="" width="740" height="139" srcset="https://techyaz.com/wp-content/uploads/2017/08/5.jpg 740w, https://techyaz.com/wp-content/uploads/2017/08/5-300x56.jpg 300w" sizes="auto, (max-width: 740px) 100vw, 740px" /></p>
<p>We can see command executed successfully. Now issue is fixed here.</p>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/">Fix SQL Server Error 15433, Level 16, State 1: Supplied parameter sid is in use</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fixing-error-15433-level-16-state-1-supplied-parameter-sid-use/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Create a Logon Trigger to Restrict sysadmin logins to connect to SQL Server for given Time Interval</title>
		<link>https://techyaz.com/sql-server/t-sql/create-logon-trigger-restrict-sysadmin-logins-connect-sql-server-given-time-interval/</link>
					<comments>https://techyaz.com/sql-server/t-sql/create-logon-trigger-restrict-sysadmin-logins-connect-sql-server-given-time-interval/#comments</comments>
		
		<dc:creator><![CDATA[Maruti Nandan]]></dc:creator>
		<pubDate>Mon, 21 Aug 2017 07:58:44 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[Logon Trigger]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=566</guid>

					<description><![CDATA[<p>I was struggling with unwanted modifications of SQL Server configurations by random SQL Server sysadmin logins who were part of our SQL Server Instance. Every time we cannot monitor what has been changed and who are doing it on your&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/t-sql/create-logon-trigger-restrict-sysadmin-logins-connect-sql-server-given-time-interval/">Create a Logon Trigger to Restrict sysadmin logins to connect to SQL Server for given Time Interval</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I was struggling with unwanted modifications of SQL Server configurations by random SQL Server sysadmin logins who were part of our SQL Server Instance. Every time we cannot monitor what has been changed and who are doing it on your non-prod servers. We generally monitor our production boxes for any unwanted activities. here i will show you how to create a Logon trigger to restrict sysadmin logins to not perform such activities. I will also show you how we can restrict them between a given time interval. Access will be allowed during office hours and restricted during out of office hours.</p>
<h3><span style="color: #000080;"><strong>Logon trigger Overview</strong></span></h3>
<p><strong>Logon Triggers</strong> fire in response to a LOGON event. It fires after the authentication phase of logging in finishes, but before the user session is actually established. Logon Triggers are very useful in tracking and restricting login events.</p>
<p>Sometimes few applications require sysadmin privilege to run and if you downgrade this access, application stops working. So, we cannot restrict sysadmin logins of such applications. There is always a scope of security breach if another login has sysadmin access except DBAs on SQL Server Instance.</p>
<p>To fix this issue, I have created a logon trigger that will restrict access of such application logins who are <strong>sysadmin </strong>on your SQL Server Instance<strong>. </strong> We can restrict them to access SQL Server directly through SSMS or any other medium. You need to pass that medium into code just like I have passed Management studio.</p>
<h3><span style="color: #000080;"><strong>Logon Trigger T-SQL Code</strong></span></h3>
<p>Below is the Logon Trigger T-SQL code which will be used to restrict any login for given time frame.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;">
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE trigger [logon_rest]
on all server for logon
as begin
declare @Program varchar(128)
declare @systemname varchar(128)
select @Program =PROGRAM_NAME,@systemname=HOST_NAME from sys.dm_exec_sessions as A
where a.session_id=@@SPID
if ORIGINAL_LOGIN() in('sa') </span><span class="kwrd" style="color: green;">/**Login For Which Access Need to restricted **/</span><span class="kwrd" style="color: blue;">
and @Program like'%Management%studio' </span><span class="kwrd" style="color: green;">/** Program via access restricted **/</span><span class="kwrd" style="color: blue;">
and
(GETDATE()&gt;(dateadd(day, datediff(day, 0, getdate()), 0) + '18:00') </span><span class="kwrd" style="color: green;">/**Last time till access allowed **/</span><span class="kwrd" style="color: blue;">
or
GETDATE()&lt;(dateadd(day, datediff(day, 0, getdate()), 0) + '09:00')) </span><span class="kwrd" style="color: green;">/**Start time from access allowed **/</span><span class="kwrd" style="color: blue;">
begin
Raiserror ('This is out of office hour',1,1)
rollback;
end
end;
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
ENABLE TRIGGER [logon_rest] ON ALL SERVER
GO
</span></strong></pre>
<h5><span style="color: #000080;"><strong>Testing</strong></span></h5>
<p>For the testing purpose, I have taken sa account as a potential application login. You can use your identified login which are running with sysadmin rights. Even we can restrict such logins to connect to SQL Server during given time frame.</p>
<p>Here we have disabled sa server level login to connect through SSMS Before 9:00 AM and Post 6:00 PM. That means server login sa cannot connect to SQL Server Instance between given time slot. You can alter the time slot as per your convenience.</p>
<p>Just for example we have tried to login on SQL server through SSMS between given time frame and here you can see the output. I am not able to connect to SQL Server anymore. You can see this in below screenshot. But at the same time you can login to the same SQL Server Instance using other sysadmin or normal login accounts which is available in sys.syslogins.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-567" src="http://techyaz.com/wp-content/uploads/2017/08/1-sa-login.jpg" alt="logon trigger" width="644" height="488" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-sa-login.jpg 644w, https://techyaz.com/wp-content/uploads/2017/08/1-sa-login-300x227.jpg 300w" sizes="auto, (max-width: 644px) 100vw, 644px" /></p>
<p>Even we can track the <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">failed login</a> attempt made on this SQL Server Instance once you can make a database connection using another login. You can check the SQL Server error logs or you can just run <strong>sp_readerrorlog</strong> stored procedure to display errors. You can see our test login attempt is showing in below screenshot on the server.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-568" src="http://techyaz.com/wp-content/uploads/2017/08/2-errorlog.jpg" alt="" width="607" height="215" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-errorlog.jpg 607w, https://techyaz.com/wp-content/uploads/2017/08/2-errorlog-300x106.jpg 300w" sizes="auto, (max-width: 607px) 100vw, 607px" /></p>
<p><span style="color: #800000;"><em><strong>Read more about SQL Server Login Issue related Articles:</strong></em></span></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">Fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">How to fix error 15434: Could not drop login as the user is currently logged in</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/" target="_blank" rel="noopener">Fixing error 15170: Login owns one or more SQL Agent Jobs</a></strong></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/t-sql/create-logon-trigger-restrict-sysadmin-logins-connect-sql-server-given-time-interval/">Create a Logon Trigger to Restrict sysadmin logins to connect to SQL Server for given Time Interval</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/t-sql/create-logon-trigger-restrict-sysadmin-logins-connect-sql-server-given-time-interval/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Fixing SAP Connectivity issue after AOAG Automatic failover</title>
		<link>https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 18 Aug 2017 19:46:24 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AOAG]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[HADR]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[sap]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=550</guid>

					<description><![CDATA[<p>We have Alwayson Availability Group configuration for our SAP systems. We faced SAP connectivity issue when application team tried to do a failover/HA testing and connect to database post failover, they were failed to connect to the current primary replica&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/">Fixing SAP Connectivity issue after AOAG Automatic failover</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We have <span style="color: #333399;"><strong><a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Alwayson Availability Group</a></strong></span> configuration for our SAP systems. We faced SAP connectivity issue when application team tried to do a failover/HA testing and connect to database post failover, they were failed to connect to the current primary replica which was secondary replica before failover.</p>
<h3><span style="color: #000080;"><strong>Automatic Failover Worked Well but Application failed to connect</strong></span></h3>
<p>I have an AOAG configuration with Automatic failover between two replicas in my environment.  Last week, we had High Availability testing for all applications. Everything was working fine if we were doing failover from Management Studio. Databases were failing over and failing back successfully.</p>
<p>Issue occurred when application team tried to connect to database server after failover. They were <span style="color: #333399;"><strong><a href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">failed to connect to the secondary replica after every failover</a></strong></span> but applications were working fine from primary replica. Below are the error details that are coming to application team during establishing database connection post failover to current primary replica (earlier secondary replica).</p>
<div class="codediv"><strong><span class="kwrd" style="color: red;">[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name &#8216;DBPROPERTIES&#8217;.<br />
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name &#8216;SVERS&#8217;.<br />
</span></strong></div>
<p>When we saw at the database level, everything was working fine.<span style="color: #333399;"><strong> <a href="https://techyaz.com/sql-server/troubleshooting/secondary-replica-not-coming-online-showing-resolving-state-automatic-failover-alwayson-availability-group-configuration/" target="_blank" rel="noopener">Secondary replica was successfully transitioning as primary replica after failover</a></strong></span> and databases were accessible from failover node but application was not able to connect to this replica. We checked all respective logins associated with the application and everything was there on secondary replica.</p>
<p>One thing we have noticed during troubleshooting that SQL login was became orphaned after each failover and we did resolved orphaned user issue manually post each failover. But there is no benefit of automatic failover if you need to establish database connection manually after each failover.</p>
<p>After spending some time, we fixed this issue. Application was not able to connect to database post failover because one of the SQL login which was used by application has different SID on secondary replica than its primary replica. I recreated this login on secondary replica with same SID which was in primary replica and this has fixed the issue. Here, I will explain step by step method to make you understand the issue and its solution.</p>
<h3><span style="color: #000080;"><strong>Resync the SID from Primary Replica</strong></span></h3>
<p>First check the current configuration of this AOAG. Run below command to get the AOAG details. We can see the configuration is running into automatic failover mode along with replica names.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: blue;"><strong>SELECT replica_server_name, availability_mode_desc, failover_mode_desc
FROM sys.availability_replicas
</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-551" src="http://techyaz.com/wp-content/uploads/2017/08/1-AOAG-details.jpg" alt="AOAG details" width="697" height="221" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-AOAG-details.jpg 697w, https://techyaz.com/wp-content/uploads/2017/08/1-AOAG-details-300x95.jpg 300w" sizes="auto, (max-width: 697px) 100vw, 697px" /></p>
<p>If you do failover between replicas then it will not throw any error in SSMS or database level. But if you will ask application team to connect to database server using Listener post failover, you will get error.</p>
<p>You will face error because SID of the login used by application is different on both replica servers. You can also get the error when the login used by application to establish database connection is not present on secondary replica. You need to sync the login, password and SID of this login to the secondary replica. Follow this tip to fix the issue that are coming due to any of the given reason.</p>
<p>The SID identifies the security context of the login and is unique within the server instance. If the login is created from a Windows user or group, it is given the Windows SID of the source principle; the Windows SID is unique within the domain. If the login is created as a legacy-style <strong>SQL Server login </strong>that requires a password, the server will generate a SID. Now check the SID of the login which is used to connect to database on primary replica.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Replace your identified login with xyz.</span><span class="kwrd" style="color: blue;">
select name,sid from syslogins
where name='xyz'
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-552" src="http://techyaz.com/wp-content/uploads/2017/08/2-check-sid.jpg" alt="check sid" width="394" height="185" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-check-sid.jpg 394w, https://techyaz.com/wp-content/uploads/2017/08/2-check-sid-300x141.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/2-check-sid-520x245.jpg 520w, https://techyaz.com/wp-content/uploads/2017/08/2-check-sid-720x340.jpg 720w" sizes="auto, (max-width: 394px) 100vw, 394px" /></p>
<p>Now run same command on secondary replica. You can see SID is different on both replicas for same login. Ideally everything should be same and in sync with primary replica that are associated with AOAG.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-553" src="http://techyaz.com/wp-content/uploads/2017/08/3-check-sid.jpg" alt="check sid" width="361" height="198" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-check-sid.jpg 361w, https://techyaz.com/wp-content/uploads/2017/08/3-check-sid-300x165.jpg 300w" sizes="auto, (max-width: 361px) 100vw, 361px" /></p>
<p>Now we need to delete this login from secondary replica and recreate it using same SID which is present on primary replica. Next, drop the login either using SSMS or T-SQL. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p>If you want to drop this login using T-SQL command then open a query window and execute below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the name of xyz with your login name which you want to delete.</span><span class="kwrd" style="color: blue;">
DROP Login 'xyz'
</span></strong></pre>
<p>You might get multiple dependency errors during dropping this login because there is possibility, this login might own few objects, agent jobs or databases on this instance. I got <span style="color: #333399;"><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/" target="_blank" rel="noopener">Error 15170 during dropping this login</a> </strong></span>which i fixed in attached tip to remove this login. You can also read below articles if you are getting different kind of DROP Login failed issues:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">How to fix error 15434: Could not drop login as the user is currently logged in</a></strong></li>
</ul>
<p>Once login will be dropped, go ahead and create same login with same password and SID which are used on primary replica. Copy the SID from <strong>image 2</strong> when you check the SID for this login on primary replica and use that during CREATE Login statement. If you don&#8217;t have this login on secondary replica yet then also you can follow same process to create the login.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--copy the SID from primary replica.</span><span class="kwrd" style="color: blue;">
CREATE Login xyz WITH password = 'password@123', CHECK_Policy=Off, SID = 0xC2Cabcdefghijk123hghj6C3
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-554" src="http://techyaz.com/wp-content/uploads/2017/08/4-create-login-sid.jpg" alt="create login" width="960" height="204" srcset="https://techyaz.com/wp-content/uploads/2017/08/4-create-login-sid.jpg 960w, https://techyaz.com/wp-content/uploads/2017/08/4-create-login-sid-300x64.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/4-create-login-sid-768x163.jpg 768w" sizes="auto, (max-width: 960px) 100vw, 960px" /></p>
<p>We can see command executed successfully. Now issue will be fixed if you don&#8217;t had this login on secondary replica and you just created it for very first time. But you might get orphaned user issue if you had this login earlier with different SID on this instance. Now we need to fix the orphaned users on the secondary replica.</p>
<h3><span style="color: #000080;"><strong>Fix Orphaned Users</strong></span></h3>
<p>Now you need to run below command to check the orphaned users on your database. Make sure that your database is working as primary otherwise you would not be able to run this command. You can failover and then run this command if database will become primary.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the dbname</span><span class="kwrd" style="color: blue;">
USE DBNAME
Go
sp_change_users_login 'report'
</span></strong></pre>
<p>If you will get your user name which was mapped to the identified login then we need to fix this orphaned user. Run below command to fix this issue.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the dbname
--Map database user xyz to login xyz.  </span></strong><span class="kwrd" style="color: blue;"><strong>
USE DBName;  
GO  
EXEC sp_change_users_login 'Update_One', 'xyz', 'xyz';  
GO </strong> 
</span></pre>
<p>Now orphaned user issue is also resolved and we have fixed the application connectivity issue that was reported after automatic failover of AOAG. You can do failover testing again to make sure application connectivity is working fine after AOAG failover.</p>
<p>I hope you like this article. Please follow us on our <strong><a href="https://www.facebook.com/Techyaz/">facebook page</a> </strong>and on<strong> <a href="https://twitter.com/Tech_yaz">Twitter </a></strong>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/">Fixing SAP Connectivity issue after AOAG Automatic failover</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15170: Login owns one or more Agent Jobs</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15170/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15170/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 18 Aug 2017 18:33:45 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=545</guid>

					<description><![CDATA[<p>I got Microsoft SQL Server error 15170 while removing a SQL Server login on one of SQL Server Instance. Microsoft SQL Server Error 15170 suggests that the login which i want to drop owns one or more SQL Server Agent jobs. Here&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/">Fix SQL Server Error 15170: Login owns one or more Agent Jobs</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got Microsoft SQL Server error 15170 while removing a SQL Server login on one of SQL Server Instance. Microsoft SQL Server Error 15170 suggests that the login which i want to drop owns one or more SQL Server Agent jobs. Here we will fix this issue by changing the owner of all identified jobs and then will drop the SQL login.</p>
<p>If you are facing different kind of DROP login failed errors, you can read below articles where i have demonstrated step by step method to fix the various kind of DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">How to fix error 15434: Could not drop login as the user is currently logged in</a></strong></li>
</ul>
<h3><span style="color: #000080;"><strong>Microsoft SQL Server Error 15170</strong></span></h3>
<p>I had to remove a SQL login on one of SQL Server instance where <strong><a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysOn Availability Group</a> </strong>is configured and running. We need to remove this login and recreate it with the same SID which are present on primary replica to fix an<span style="color: #0000ff;"><strong><a href="https://techyaz.com/sql-server/alwayson/fixing-sap-connectivity-issue-aoag-automatic-failover/" target="_blank" rel="noopener"> AOAG Automatic failover issue</a>.</strong></span> Login was failed to drop because of SQL Server error 15170 which suggests that this login owns one or more SQL Server Agent jobs. Error details are given below.</p>
<div class="codediv"><span class="kwrd" style="color: red;"><strong>Drop failed for Login &#8220;xyz&#8221;</strong><br />
<strong> The login is the owner of 3 job(s). You must delete or reassign these jobs before the login can be dropped. (Microsoft SQL Server, Error:15170)</strong><br />
</span></div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-546" src="http://techyaz.com/wp-content/uploads/2017/08/1-error-15170.jpg" alt="error 15170" width="713" height="635" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-error-15170.jpg 713w, https://techyaz.com/wp-content/uploads/2017/08/1-error-15170-300x267.jpg 300w" sizes="auto, (max-width: 713px) 100vw, 713px" /></p>
<p>As error clearly says, that one or more Agent jobs are owned by this login so let us check the details about it. Expand <strong>SQL Server Agent</strong> followed by <strong>Jobs</strong> folder of your SQL Server Instance connected in SSMS. You can see below jobs were there on SQL Server Instance.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-547" src="http://techyaz.com/wp-content/uploads/2017/08/2-agent-jobs.jpg" alt="agent jobs" width="471" height="215" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-agent-jobs.jpg 471w, https://techyaz.com/wp-content/uploads/2017/08/2-agent-jobs-300x137.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/2-agent-jobs-980x450.jpg 980w" sizes="auto, (max-width: 471px) 100vw, 471px" /></p>
<h3><span style="color: #000080;"><strong>Solution</strong></span></h3>
<p>Now check the properties of these agent jobs to check the job owner. Double click on identified agent job. You will get below image. Here you can see job owner is showing as same account which we are trying to drop. Change it to sa and click on ok button to apply the change. Repeat the same to the all three agent jobs.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-548" src="http://techyaz.com/wp-content/uploads/2017/08/3-job-owner.jpg" alt="job owner" width="709" height="635" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-job-owner.jpg 709w, https://techyaz.com/wp-content/uploads/2017/08/3-job-owner-300x269.jpg 300w" sizes="auto, (max-width: 709px) 100vw, 709px" /></p>
<p>Now owner of agent jobs is changed to sa. Next step is to go ahead and drop the login again. you can do it by either SSMS or T-SQL. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p>If you want to drop this login using T-SQL command then open a query window and execute below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the name of Login_name with your login name which you want to delete.</span><span class="kwrd" style="color: blue;">
DROP Login 'LOGIN_NAME'
</span></strong></pre>
<p>This time your login will be dropped successfully. If you are still facing some another issue during dropping this login, you can read below articles where i have demonstrated step by step method to fix the DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a></strong></li>
</ul>
<p>Here, we have fixed Microsoft SQL Server error 15170. I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/">Fix SQL Server Error 15170: Login owns one or more Agent Jobs</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-15170/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15434: Could not drop login &#8216;Domain\abc&#8217; as the user is currently logged in</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Thu, 10 Aug 2017 11:24:35 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=419</guid>

					<description><![CDATA[<p>Generally, Microsoft SQL Server error 15434 appears during removing a SQL Server login. This error generates when you try to drop a login that has an active open connection to SQL Server Instance. Here i will discuss all the aspects&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/">Fix SQL Server Error 15434: Could not drop login &#8216;Domain\abc&#8217; as the user is currently logged in</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Generally, Microsoft SQL Server error 15434 appears during removing a SQL Server login. This error generates when you try to drop a login that has an active open connection to SQL Server Instance. Here i will discuss all the aspects of this error and the its resolution.</p>
<p>If you are facing different kind of DROP login failed errors, you can read below articles where i have demonstrated step by step method to fix the various kind of DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix Error 15141: Server principal owns one or more endpoints.</a></strong></li>
</ul>
<h3><span style="color: #333399;"><strong>Microsoft SQL Server Error 15434</strong></span></h3>
<p>This error generates when a login has made a connection to the SQL Server Instance and you are trying to drop the same login. Solution to fix this issue is to close all sessions which are opened by this login and then drop it. You can get the details about the sessions which are open using this login id either by sp_who2 or by DMV sys.dm_exec_sessions.</p>
<p>I had to remove a domain login on one of SQL Server instance but login was failed to drop because of SQL Server error 15434 which suggests that the login is currently logged in. Error details are given below.</p>
<p><span class="kwrd" style="color: red;">Drop failed for Login &#8220;domain\abc&#8221;<br />
Could not drop login &#8216;domain\abc&#8217; as the user is currently logged in. (Microsoft SQL Server, Error: 15434)<br />
</span></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-421" src="http://techyaz.com/wp-content/uploads/2017/08/1-error-15434.jpg" alt="error 15434" width="703" height="625" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-error-15434.jpg 703w, https://techyaz.com/wp-content/uploads/2017/08/1-error-15434-300x267.jpg 300w" sizes="auto, (max-width: 703px) 100vw, 703px" /></p>
<p>As error clearly says that above login is currently logged in. Run below T-SQL code to get the details about the sessions or connections this login has made to the SQL Server Instance.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;">SELECT login_name, * FROM sys.dm_exec_sessions
WHERE login_name = 'xyz\abc'
Go
</span></strong></pre>
<p>You will see the details for this login along with the session id in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-422" src="http://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID-1024x181.png" alt="get the spid" width="1024" height="181" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID-1024x181.png 1024w, https://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID-300x53.png 300w, https://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID-768x136.png 768w, https://techyaz.com/wp-content/uploads/2017/08/2-get-the-SPID.png 1074w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></p>
<h3><span style="color: #333399;"><strong>Solution</strong></span></h3>
<p>Now we have identified the session id which are running using this login id which we want to drop. Now next step is to kill this session. Make sure to check the SQL code running behind this session id. If it is not critical go ahead and drop the login or if any DML or other operations are running about which you are not aware of, please contact application owners to get the details about this session id. <strong>Don&#8217;t kill any session id that you are not aware of.</strong> Now go ahead and kill above session which is running using our login id. I am going ahead to kill this session because i know what is running under this session which is not critical.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span class="kwrd" style="color: green;">--Replace the session id 53 with your session id.</span><span class="kwrd" style="color: #0000ff;">
Kill 53
GO
</span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-423" src="http://techyaz.com/wp-content/uploads/2017/08/3-kill-process.jpg" alt="kill process" width="431" height="131" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-kill-process.jpg 431w, https://techyaz.com/wp-content/uploads/2017/08/3-kill-process-300x91.jpg 300w" sizes="auto, (max-width: 431px) 100vw, 431px" /><br />
We can see command executed successfully. You can recheck whether this session is still open or not by executing same command which we have executed in first section.<br />
<img loading="lazy" decoding="async" class="aligncenter size-large wp-image-424" src="http://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes-1024x196.jpg" alt="recheck processes" width="1024" height="196" srcset="https://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes-1024x196.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes-300x57.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes-768x147.jpg 768w, https://techyaz.com/wp-content/uploads/2017/08/4-recheck-processes.jpg 1081w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><br />
We can see, session id 53 is no more active and disappeared from the SQL Server transactions. Next step is go ahead and drop the login again. This time your login will be dropped successfully.</p>
<p>If you are still facing same issue during dropping the login and get this error again then you can check SQL Server services log on accounts. Sometimes if you run SQL Server services using the account which you want to drop throws same error. If this is the case then your next step is to change the logon account to some other domain account to release this login. You can see this in below image. Change the log on account of all SQL Server services if they are running using this account. Once you made the changes to the services, restart SQL Server service to bring new account in use by SQL Server.<br />
<img loading="lazy" decoding="async" class="aligncenter wp-image-425 size-full" src="http://techyaz.com/wp-content/uploads/2017/08/5-change-service-account-e1502364188215.jpg" alt="check service accounts" width="423" height="481" srcset="https://techyaz.com/wp-content/uploads/2017/08/5-change-service-account-e1502364188215.jpg 423w, https://techyaz.com/wp-content/uploads/2017/08/5-change-service-account-e1502364188215-264x300.jpg 264w" sizes="auto, (max-width: 423px) 100vw, 423px" /><br />
Now go ahead and drop the account again. This time it will work and your login will be removed. You will not face Microsoft SQL Server Error 15434 anymore. You can do it by either SSMS or T-SQL. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p>If you want to drop this login using T-SQL command then open a query window and execute below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the name of Login_name with your login name which you want to delete.</span><span class="kwrd" style="color: blue;">
DROP Login 'LOGIN_NAME'
</span></strong></pre>
<p>If you are getting some another issue during dropping this login, you can read below articles where i have demonstrated step by step method to fix the DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix Error 15141: Server principal owns one or more endpoints.</a></strong></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/">Fix SQL Server Error 15434: Could not drop login &#8216;Domain\abc&#8217; as the user is currently logged in</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</title>
		<link>https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/</link>
					<comments>https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 09 Aug 2017 07:51:58 +0000</pubDate>
				<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=411</guid>

					<description><![CDATA[<p>I got Microsoft SQL Server error 15141 while removing a SQL Server domain login on one of instance where AlwaysOn is configured. SQL Server Error 15141 suggests that the login which i want to drop owns AlwaysON endpoints. Here we&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/">Fix SQL Server Error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I got Microsoft SQL Server error 15141 while removing a SQL Server domain login on one of instance where AlwaysOn is configured. SQL Server Error 15141 suggests that the login which i want to drop owns AlwaysON endpoints. Here we will fix this issue by changing the owner of endpoint and then will drop the identified domain login.</p>
<p>If you are facing different kind of DROP login failed errors, you can read below articles where i have demonstrated step by step method to fix the various kind of DROP login failed errors:</p>
<ul>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></li>
<li><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></li>
</ul>
<h3><span style="color: #000080;"><strong>Microsoft SQL Server Error 15141</strong></span></h3>
<p>I had to remove a domain login on one of SQL Server instance where AlwaysOn is configured and running. Login was failed to drop because of Microsoft SQL Server error 15141 which suggests that this login owns one or more endpoints. Error details are given below:<br />
<span class="kwrd" style="color: red;"><br />
Drop failed for Login &#8220;Login Name&#8221;<br />
The server principal owns one or more endpoint(s) and cannot be dropped. (Microsoft SQL Server, Error:15141)<br />
</span></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-412" src="http://techyaz.com/wp-content/uploads/2017/08/1-error-15141.jpg" alt="error 15141" width="713" height="633" srcset="https://techyaz.com/wp-content/uploads/2017/08/1-error-15141.jpg 713w, https://techyaz.com/wp-content/uploads/2017/08/1-error-15141-300x266.jpg 300w" sizes="auto, (max-width: 713px) 100vw, 713px" /></p>
<p>As error clearly says that one or more endpoints are owned by this login so let us check the details about endpoints. Run below T-SQL code to get the details of endpoint.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: blue;">SELECT n.name, a.*  FROM sys.endpoints a
inner join sys.server_principals n on a.principal_id=n.principal_id
Go
</span></strong></pre>
<p>You will see the endpoint details in below screenshot along with the login id who owns the endpoint. I have blured it because of privacy.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-413" src="http://techyaz.com/wp-content/uploads/2017/08/2-check-details.jpg" alt="check endpoint ownership" width="986" height="307" srcset="https://techyaz.com/wp-content/uploads/2017/08/2-check-details.jpg 986w, https://techyaz.com/wp-content/uploads/2017/08/2-check-details-300x93.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/2-check-details-768x239.jpg 768w" sizes="auto, (max-width: 986px) 100vw, 986px" /></p>
<h3><span style="color: #000080;"><strong>Solution</strong></span></h3>
<p>As we can see that endpoint is owned by this login so now we will change the owner of this endpoint to break the dependency which are the main reason behind this SQl Server error 15141. Now next step is to change the owner to some another login. You can also transfer the ownership to system account sa.</p>
<p>We will use ALTER Authorization statement to transfer ownership of this endpoint from existing server level login to some another server level login. We can not set the ownership to database level users. ALTER AUTHORIZATION can be used to change the ownership of any entity that has an owner. Run below command to change the owner of above endpoint to a login Domain\abc5.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Replace the login id [Domain\abc5] with your login.</span><span class="kwrd" style="color: #0000ff;">
ALTER Authorization on endpoint::Hadr_endpoint to [Domain\abc5]
GO
</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-414" src="http://techyaz.com/wp-content/uploads/2017/08/3-change-owner.jpg" alt="transfer ownership to another login" width="633" height="131" srcset="https://techyaz.com/wp-content/uploads/2017/08/3-change-owner.jpg 633w, https://techyaz.com/wp-content/uploads/2017/08/3-change-owner-300x62.jpg 300w" sizes="auto, (max-width: 633px) 100vw, 633px" /><br />
We can see command executed successfully. You can recheck the ownership by executing same command which we have executed in first section. Once change is done. next step is to drop the login.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-415" src="http://techyaz.com/wp-content/uploads/2017/08/4-check-details.jpg" alt="recheck endpoint ownership" width="979" height="235" srcset="https://techyaz.com/wp-content/uploads/2017/08/4-check-details.jpg 979w, https://techyaz.com/wp-content/uploads/2017/08/4-check-details-300x72.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/4-check-details-768x184.jpg 768w" sizes="auto, (max-width: 979px) 100vw, 979px" /><br />
We can see, now ownership of this endpoint is set to another login. Next step is go ahead and drop the login again. you can do it by either SSMS or T-SQL. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand the security folder.</li>
<li>Expand the Logins folder.</li>
<li>Right click and choose delete on the identified login which needs to be deleted.</li>
<li>Click on Ok button of the login deletion window.</li>
</ul>
<p>If you want to drop this login using T-SQL command then open a query window and execute below command.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--change the name of Login_name with your login name which you want to delete.</span><span class="kwrd" style="color: blue;">
DROP Login 'LOGIN_NAME'
</span></strong></pre>
<p>This time your login will be dropped successfully. If you are still facing some another issue during dropping this login, you can read below articles where i have demonstrated step by step method to fix the DROP login failed errors:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">How to fix Error 15174: Login owns one or more databases.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">How to fix Error 15173: Revoke the permissions before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 &amp; Error 3729: DROP login failed</a></strong></li>
</ul>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/">Fix SQL Server Error 15141: The server principal owns one or more endpoint(s) and cannot be dropped</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/alwayson/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 15173: Revoke the permission(s) before dropping the login.</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15173/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15173/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 04 Aug 2017 08:49:49 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=383</guid>

					<description><![CDATA[<p>A login was failed to drop from a SQL Server instance with an error code 15173. As Microsoft SQL Server error 15173 suggests that this login has granted some permissions to other logins. Let us check the details and then&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/">Fix SQL Server Error 15173: Revoke the permission(s) before dropping the login.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A login was failed to drop from a SQL Server instance with an error code 15173. As Microsoft SQL Server error 15173 suggests that this login has granted some permissions to other logins. Let us check the details and then fix this issue so that you can drop such logins without any issue.</p>
<h3><span style="color: #800000;"><strong>Microsoft SQL Server Error 15173</strong></span></h3>
<p>Login was failed to drop because of SQL Server error 15173. This error comes when a login having server level rights has granted permission to any server principal. The details of Microsoft SQL Server error 15173 is given below.</p>
<div class="codediv"><span style="color: #ff0000;">Drop failed for login &#8216;xyz&#8217;.</span><br />
<span style="color: #ff0000;"> Login &#8216;xyz&#8217; has granted one or more permission(s). Revoke the permission(s) before dropping the login. (Microsoft SQL Server, Error:15173)</span></div>
<p><img loading="lazy" decoding="async" class="wp-image-384 alignright" src="http://techyaz.com/wp-content/uploads/2017/08/error-15173-1024x576.jpg" alt="error 15173" width="373" height="210" srcset="https://techyaz.com/wp-content/uploads/2017/08/error-15173-1024x576.jpg 1024w, https://techyaz.com/wp-content/uploads/2017/08/error-15173-300x169.jpg 300w, https://techyaz.com/wp-content/uploads/2017/08/error-15173-768x432.jpg 768w, https://techyaz.com/wp-content/uploads/2017/08/error-15173.jpg 1280w" sizes="auto, (max-width: 373px) 100vw, 373px" /></p>
<p>You can check the details about the grantee by running below command. You will see the grantee_principal_id and grantor_principal_id column along with other details. Grantor_principal_id will be the id of that login which you want to delete. You can see class_desc and permission_name column to see the permission type and permission category.</p>
<pre class="brush: sql; title: ; notranslate" title=""><span style="color: #0000ff;"><strong>SELECT * FROM sys.server_permissions
Where grantor_principal_id= (Select principal_id from sys.server_principals where name = 'xyz')
</strong></span></pre>
<p>You might get such issues if you have configured AlwaysOn availability group or database mirroring because there might be possibility that your login has granted some permission to endpoint so you need to revoke that permission to fix this issue.</p>
<h3><span style="color: #800000;"><strong>Solution</strong></span></h3>
<p>The solution to fix this issue is to revoke the access which you have granted. Run below command to revoke the access for endpoints. This solution is valid only in case if you have granted access on endpoint. If you have granted access on login then you should keep reading this article.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #0000ff;"><span style="color: #008000;">--Here xyz was grantor.
--Make sure to revoke the access level which you get in the output of above script. 
--You can get this by focusing on permission_name and state_desc column. In my case, it was view definition and state_desc was GRANT.</span>
USE Master
Go
REVOKE CONNECT ON ENDPOINT:: [hadr_endpoint] TO [xyz]
</span></strong></pre>
<p>Once command will be executed successfully, you are able to drop that login. Do let me know in comment section if you are still facing the issue. You can try below T-SQL to revoke the access from login if you get an output for logins not endpoint.</p>
<p>If this access is assigned to login and not endpoint then you should run below command to revoke the access. Here we are trying to drop login xyz but it was failed because xyz login has granted access to login abc. So, we will revoke the access to drop the user.</p>
<pre><span style="color: #0000ff;"><strong>USE master</strong></span>
<span style="color: #0000ff;"><strong>REVOKE VIEW DEFINITION ON LOGIN:: xyz FROM [abc]</strong></span></pre>
<p>Go ahead and drop the login which you wanted to drop.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span style="color: #008000;"><span style="color: #0000ff;">--change the name of Login_name with your login name.</span>
<span style="color: #0000ff;">DROP Login 'LOGIN_NAME'
</span></span></strong></pre>
<p>You can also revoke this access level using SSMS/GUI as well. Connect to SQL Server Instance in SSMS, Expand security folder followed by logins folder. Double click on the login and go to securables from left side pane. You can uncheck the permissions allocated to this login and click on ok to apply the changes.</p>
<p>You can click on attached link if you want to learn about another <a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Error 15174 which comes during drop Login statement</a>.</p>
<p>I hope you like this article. Please follow us on our <a href="https://www.facebook.com/Techyaz/">facebook page</a> and on <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/">Fix SQL Server Error 15173: Revoke the permission(s) before dropping the login.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-15173/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
