<?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>user - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/user/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Mon, 14 May 2018 15:30:47 +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>user - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Linux User Administration &#8211; Add, Delete &#038; Modify User Accounts</title>
		<link>https://techyaz.com/linux/linux-user-administration-add-delete-modify-user-accounts/</link>
					<comments>https://techyaz.com/linux/linux-user-administration-add-delete-modify-user-accounts/#respond</comments>
		
		<dc:creator><![CDATA[Angelo Marquez]]></dc:creator>
		<pubDate>Mon, 12 Mar 2018 10:41:35 +0000</pubDate>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[RedHat Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[red hat Linux]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1906</guid>

					<description><![CDATA[<p>In IT’s World, it is common to hear about system users, especially if you work in the administration of systems under that environment. GNU/LINUX is a multiuser and reliable operating system in terms of security, but it is always good&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/linux/linux-user-administration-add-delete-modify-user-accounts/">Linux User Administration &#8211; Add, Delete &#038; Modify User Accounts</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In IT’s World, it is common to hear about system users, especially if you work in the administration of systems under that environment. GNU/LINUX is a multiuser and reliable operating system in terms of security, but it is always good to know the basics of managing system users. Well, today we&#8217;ll be talking about creating, modifying and deleting users in the GNU/LINUX systems. Here, i will explain how to add user to Linux and Modify or remove user to Linux machine.</p>
<h3><span style="color: #333399;">USERS IN GNU/LINUX<strong> </strong></span></h3>
<p>The first thing we need to know is that, in GNU/LINUX there are different types of users already predefined and each of them have different characteristics for the correct functioning of the system. The first of these is the <strong>root</strong> user.</p>
<p><strong>Root user</strong></p>
<p>The Root user is the administrator of the operating system, with all options and permissions to perform operations and changes in the system. Its main features are:</p>
<ul>
<li>It is the only user account with system-wide privileges.</li>
<li>In charge of controlling the administration of user accounts.</li>
<li>It is the only user that can stop the system.</li>
<li>The root user can install, uninstall and update basic system programs and libraries.</li>
</ul>
<p>In other words, the root user is the all-powerful user of the system.</p>
<p><strong>Special Users</strong><strong> </strong></p>
<p>They are also called users without login. Their roles in the system are determined by the addition of installed programs. They are distinguished by:</p>
<ul>
<li>They are created (usually) automatically at the time of Linux or application installation.</li>
<li>It does not have all the privileges of the root user, but depending on the account they assume different root privileges.</li>
<li>They are created when installing the system or any of its extra components.</li>
<li>Some of them are: bin, daemon, adm, lp, sync, shutdown, mail, operator, squid, apache</li>
</ul>
<p><strong>Common Users</strong><strong> </strong></p>
<p>These last users are us. That is, they are accounts that are created to use all accessible parts of the system, such as assigned programs and directories. They have a Home directory where they can easily access their documents and files.</p>
<ul>
<li>Such users have only full privileges in their working directory or HOME.</li>
<li>They are used for individual users.</li>
<li>These users do not have privileges to manage the system or install software.<strong> </strong></li>
</ul>
<h5><span style="color: #993300;"><strong>How to Create or Add USERS TO Linux Systems?</strong></span></h5>
<p>The adduser command is a &#8220;new&#8221; alternative to the useradd binary that allows us to add common users to our GNU/LINUX distribution. It is much more &#8220;friendly&#8221; and intuitive than useradd and allows us to add additional information about the new user. Here we will learn how to create user on Linux system.</p>
<p>In order to use the adduser command we must be root users, for that reason write the following command in a terminal</p>
<pre><span style="color: #008000;"><strong>#Connect using su.</strong></span>
<span style="color: #0000ff;"><strong>su</strong></span></pre>
<p><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-1907" src="http://techyaz.com/wp-content/uploads/2018/03/1-su-min.png" alt="" width="648" height="110" srcset="https://techyaz.com/wp-content/uploads/2018/03/1-su-min.png 648w, https://techyaz.com/wp-content/uploads/2018/03/1-su-min-300x51.png 300w" sizes="(max-width: 648px) 100vw, 648px" /></p>
<p>You need to write the root password then we can use adduser. The most basic way to use the adduser command is:</p>
<pre><span style="color: #0000ff;"><strong>adduser new_user</strong><strong> </strong></span></pre>
<p>where new_user is the name of user account. With this &#8220;basic&#8221; form a new user is created and by giving Enter we are asked to enter the new password for this new user account.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-1908" src="http://techyaz.com/wp-content/uploads/2018/03/2-adduser-min.png" alt="Add Linux User" width="599" height="191" srcset="https://techyaz.com/wp-content/uploads/2018/03/2-adduser-min.png 599w, https://techyaz.com/wp-content/uploads/2018/03/2-adduser-min-300x96.png 300w" sizes="(max-width: 599px) 100vw, 599px" /></p>
<p>Type the password for your new user account and press Enter. Prompt will ask you to reenter the same password. Re-enter the password and press enter button.</p>
<p><img decoding="async" class="aligncenter size-full wp-image-1909" src="http://techyaz.com/wp-content/uploads/2018/03/3-enter-password-min.png" alt="Set Password for New User in Linux" width="567" height="193" srcset="https://techyaz.com/wp-content/uploads/2018/03/3-enter-password-min.png 567w, https://techyaz.com/wp-content/uploads/2018/03/3-enter-password-min-300x102.png 300w" sizes="(max-width: 567px) 100vw, 567px" /></p>
<p>After that you will be asked for any additional information such as Full Name, phone number etc.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1910" src="http://techyaz.com/wp-content/uploads/2018/03/4-fullName-min.png" alt="Enter User Account Details" width="588" height="244" srcset="https://techyaz.com/wp-content/uploads/2018/03/4-fullName-min.png 588w, https://techyaz.com/wp-content/uploads/2018/03/4-fullName-min-300x124.png 300w" sizes="auto, (max-width: 588px) 100vw, 588px" /></p>
<p>At the end, prompt will ask us to confirm the information provided. Type Y to proceed if all information is correct.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1911" src="http://techyaz.com/wp-content/uploads/2018/03/5-enter-details-min.png" alt="Enter User Details" width="587" height="343" srcset="https://techyaz.com/wp-content/uploads/2018/03/5-enter-details-min.png 587w, https://techyaz.com/wp-content/uploads/2018/03/5-enter-details-min-300x175.png 300w" sizes="auto, (max-width: 587px) 100vw, 587px" /></p>
<p>Now, as mentioned above, that is the most basic way to create a user but adduser also has options and alternatives to create users. These alternatives are given by the options that can be added to the command, some of them are:</p>
<pre><strong><span style="color: #0000ff;">adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID]</span></strong>
<strong><span style="color: #0000ff;">[--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup GROUP | --gid ID]</span></strong>
<strong><span style="color: #0000ff;">[--disabled-password] [--disabled-login] [--add_extra_groups] USER

</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1912" src="http://techyaz.com/wp-content/uploads/2018/03/6-adduser-options-min.png" alt="Add Linux User options" width="691" height="562" srcset="https://techyaz.com/wp-content/uploads/2018/03/6-adduser-options-min.png 691w, https://techyaz.com/wp-content/uploads/2018/03/6-adduser-options-min-300x244.png 300w" sizes="auto, (max-width: 691px) 100vw, 691px" /></p>
<p>You can see various options available with adduser command in above screenshot. Let&#8217;s look at example. If you would like to add a user named <em>angelob</em>, and set their home directory to <em>/opt/angelob/</em> the the command will be as follows.</p>
<pre><strong><span style="color: #0000ff;">adduser --home /opt/angelob/ angelob</span></strong></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1913" src="http://techyaz.com/wp-content/uploads/2018/03/7-adduser-min.png" alt="Add User" width="634" height="192" srcset="https://techyaz.com/wp-content/uploads/2018/03/7-adduser-min.png 634w, https://techyaz.com/wp-content/uploads/2018/03/7-adduser-min-300x91.png 300w" sizes="auto, (max-width: 634px) 100vw, 634px" /></p>
<p>And then it will ask us for the new password and basic user information. This way you can add user to Linux system.</p>
<h5><span style="color: #993300;"><strong>How to Delete Linux User Accounts?</strong></span><strong> </strong></h5>
<p>As in above section we have learnt how to create user on Linux system. Here i will explain how remove user from Linux system. Removing users from the Linux system is simple and the command to do so is <em><strong>userdel</strong></em> and has many fewer options to make the task. You can see the descriptions for this command in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1914" src="http://techyaz.com/wp-content/uploads/2018/03/8-deleteuser-min.png" alt="Delete Linux User" width="704" height="254" srcset="https://techyaz.com/wp-content/uploads/2018/03/8-deleteuser-min.png 704w, https://techyaz.com/wp-content/uploads/2018/03/8-deleteuser-min-300x108.png 300w" sizes="auto, (max-width: 704px) 100vw, 704px" /></p>
<p>The easiest way to delete a user is to remove it by running below command. Here user is the name of user account.</p>
<pre><span style="color: #0000ff;"><strong><span style="color: #008000;">#user is the name of user account.</span>
userdel user</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1915" src="http://techyaz.com/wp-content/uploads/2018/03/9-deleteuser-min.png" alt="Remove Linux User" width="605" height="103" srcset="https://techyaz.com/wp-content/uploads/2018/03/9-deleteuser-min.png 605w, https://techyaz.com/wp-content/uploads/2018/03/9-deleteuser-min-300x51.png 300w" sizes="auto, (max-width: 605px) 100vw, 605px" /></p>
<p>We can also delete your entire personal directory with the -r option. Run below command to do this.</p>
<pre><span style="color: #0000ff;"><strong>userdel -r user</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1916" src="http://techyaz.com/wp-content/uploads/2018/03/10-userdeletion-min.png" alt="Drop Linux user" width="629" height="98" srcset="https://techyaz.com/wp-content/uploads/2018/03/10-userdeletion-min.png 629w, https://techyaz.com/wp-content/uploads/2018/03/10-userdeletion-min-300x47.png 300w" sizes="auto, (max-width: 629px) 100vw, 629px" /></p>
<h5><span style="color: #993300;"><strong>How to Modify Linux User Accounts?</strong><strong> </strong></span></h5>
<p>I have shown how to remove Linux user  in above section. Here, i will explain how to modify a Linux user. To modify users in the GNU/LINUX system we use the command <strong><em>usermod</em></strong>. We can see in the following image the possibilities shown in command:</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1917" src="http://techyaz.com/wp-content/uploads/2018/03/11-modifyuser-min.png" alt="Modify Linux User" width="705" height="572" srcset="https://techyaz.com/wp-content/uploads/2018/03/11-modifyuser-min.png 705w, https://techyaz.com/wp-content/uploads/2018/03/11-modifyuser-min-300x243.png 300w" sizes="auto, (max-width: 705px) 100vw, 705px" /></p>
<p>For example, if we wanted to change the password of a created user, it would be as follows.</p>
<pre><span style="color: #008000;"><strong>#user is the name of Linux user account.</strong></span>
<span style="color: #0000ff;"><strong>usermod -p ‘new_password’ user</strong></span></pre>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1918" src="http://techyaz.com/wp-content/uploads/2018/03/12-modifyuser-min.png" alt="modify linux users" width="654" height="109" srcset="https://techyaz.com/wp-content/uploads/2018/03/12-modifyuser-min.png 654w, https://techyaz.com/wp-content/uploads/2018/03/12-modifyuser-min-300x50.png 300w" sizes="auto, (max-width: 654px) 100vw, 654px" /></p>
<p>Obviously this method is not recommended because it leaves the password visible. Be careful. Read below article if you want to change your Linux user account password.</p>
<ul>
<li><strong><a href="http://techyaz.com/rhel/how-to-reset-or-change-user-password-on-linux/" target="_blank" rel="noopener">How to Reset or Change User Password on RHEL?</a></strong></li>
</ul>
<p>Another useful example is to move the personal folder of the desired user to another one, for it we must combine the options -d and -m in the following way.</p>
<p><span style="color: #0000ff;"><strong>usermod -d /opt/angelob1/ -m angelob</strong></span></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1919" src="http://techyaz.com/wp-content/uploads/2018/03/13-modifyuser-min.png" alt="Modify Linux user" width="619" height="107" srcset="https://techyaz.com/wp-content/uploads/2018/03/13-modifyuser-min.png 619w, https://techyaz.com/wp-content/uploads/2018/03/13-modifyuser-min-300x52.png 300w" sizes="auto, (max-width: 619px) 100vw, 619px" /></p>
<p>With the rest of the options, we only have to place them according to our needs.</p>
<p>In conclusion we can say that the administration of GNU/LINUX users is a matter for system administrators, the subject is wide and with many options to take into account for the creation of them.</p>
<p><em>Adduser</em> simplifies the creation of user accounts and <em>usermod</em> allows us to modify them in a very fast and dynamic way. And if a user has already completed his life cycle in the system, we can remove it with <em>userdel</em>.</p>
<p>I hope this small guide has been useful to understand a little bit about GNU/LINUX users, clarifying that the commands explained in the article can be used in all popular distributions such as Ubuntu, Red Hat, Suse, Debian and others.<br />
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="http://techyaz.com/rhel/red-hat-enterprise-linux-interview-questions-answers/" target="_blank" rel="noopener">RHEL Interview Questions and Answers</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>
<li><strong><a href="http://techyaz.com/rhel/install-htop-monitor-linux-processes/" target="_blank" rel="noopener">How to Install and Use Htop to Monitor Linux Processes?</a></strong></li>
<li><strong><a href="http://techyaz.com/debian/how-to-install-debian-9-stretch/" target="_blank" rel="noopener">Install Debian 9 Stretch in Step by Step Process</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/linux/linux-user-administration-add-delete-modify-user-accounts/">Linux User Administration &#8211; Add, Delete &#038; Modify User Accounts</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/linux/linux-user-administration-add-delete-modify-user-accounts/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 15138: Dropping User that owned Schema &#038; Error 3729: Schema that referenced to the object</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 04 Aug 2017 12:02:15 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Drop Login Failed]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<category><![CDATA[user]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=391</guid>

					<description><![CDATA[<p>Here we will learn how to fix Microsoft SQL Server error 15138 &#38; error 3729 that we receive while dropping a database user and a schema in SQL Server.  Let us check the details to fix this issue one after&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/">Fix SQL Server Error 15138: Dropping User that owned Schema &#038; Error 3729: Schema that referenced to the object</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Here we will learn how to fix Microsoft SQL Server error 15138 &amp; error 3729 that we receive while dropping a database user and a schema in SQL Server.  Let us check the details to fix this issue one after another.</p>
<h3><span style="color: #800000;"><strong>Microsoft SQL Server Error 15138</strong></span></h3>
<p>I have discussed similar type of issue in my last tip, where a server level login was owner of some databases which causes to <a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">fail the login removal and throws error 15174</a>. We changed the ownership and then tried to drop that login and it was successful.</p>
<p>Microsoft SQL Server Error 15138 which i am discussing in this tip is also similar kind of error. Here, user has owned some schemas at database level. We will do the same thing, we will change the owner of identified schema and drop the user.</p>
<p>The details of SQL Server error 15138 is given below.</p>
<div class="codediv"><span class="kwrd" style="color: red;">Drop failed for User &#8216;xyz&#8217;.<br />
The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error:15138)</span></div>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-392" src="http://techyaz.com/wp-content/uploads/2017/08/error-15138.png" alt="error 15138" width="618" height="268" srcset="https://techyaz.com/wp-content/uploads/2017/08/error-15138.png 618w, https://techyaz.com/wp-content/uploads/2017/08/error-15138-300x130.png 300w" sizes="auto, (max-width: 618px) 100vw, 618px" /></p>
<p>As error clearly says that a schema is owned by this user in the database so let us check the schema that is owned by this user. Please follow the below process to check the owned schema for an user in the database.</p>
<ul>
<li>Connect to SQL Server Instance in SSMS.</li>
<li>Expand the database folder followed by the actual database name in which your user exists or created.</li>
<li>Expand Security folder inside your target database followed by the Users folder and double click on the target user which you want to drop.</li>
<li>You can see a section named &#8220;Owned Schemas. Here you can see the schemas that are owned by this user.</li>
</ul>
<p>If you find any schema that is owned by this user in above steps, you need to change the owner from this user to some other user or you can change it to dbo as well. See the below screenshot of the owned schema for a user.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-393" src="http://techyaz.com/wp-content/uploads/2017/08/owned-schema.jpg" alt="owned schema" width="474" height="372" srcset="https://techyaz.com/wp-content/uploads/2017/08/owned-schema.jpg 474w, https://techyaz.com/wp-content/uploads/2017/08/owned-schema-300x235.jpg 300w" sizes="auto, (max-width: 474px) 100vw, 474px" /></p>
<h3><span style="color: #800000;"><strong>Solution</strong></span></h3>
<p>Now we have identified the schema which is owned by this user. Our Next step is to change is owner of the identified schema and then drop the login.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;"> --Change DBName with your database name and Schema_Name with your schema name which is owned by this user.</span>
<span class="kwrd" style="color: blue;">USE [DBName] </span>
<span class="kwrd" style="color: blue;">G0 </span>
<span class="kwrd" style="color: blue;">Alter Authorization ON Schema::[SCHEMA_NAME] TO [dbo] </span>
<span class="kwrd" style="color: blue;">Go</span></strong></pre>
<p>Once above command will execute, next step is to drop the user again. Run below command to drop the user.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Change DBName with your database name where user exists and USERNAME with user name which you want to drop.</span>
<span class="kwrd" style="color: blue;">USE [DBName] </span>
<span class="kwrd" style="color: blue;">Go </span>
<span class="kwrd" style="color: blue;">DROP USER USERNAME </span>
<span class="kwrd" style="color: blue;">Go</span></strong></pre>
<p>This time it will work and user will drop from the database. You can also delete this user from SSMS by right click on the user and choose the delete option. SSMS way is given below:</p>
<ul>
<li>Connect to target SQL Server Instance.</li>
<li>Expand Database folder in which user exists.</li>
<li>Expand the Security folder and then Users folder to get the target user name.</li>
<li>Right click and choose delete on the identified user which needs to be deleted.</li>
<li>Click on Ok button of the user deletion window.</li>
</ul>
<p>There are many reasons which causes to fail the user or login deletion. You can find many errors and their solutions in given links. Learn to fix:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Error Code 15174: Login Owns one or more databases(s). Change the owner of database(s) before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">Error Code 15173: Revoke the permission(s) before dropping the login.</a></strong></li>
</ul>
<h3><span style="color: #800000;"><strong>Microsoft SQL Server Error 3729</strong></span></h3>
<p>We have seen how to drop an user who was owner of a schema in above section. Now we will understand how to drop a schema that is referenced by an object. If you try to run DROP Schema statement and that particular schema is referenced to some object you will get below error. The details of SQL Server error 3729 is given below.</p>
<div class="codediv"><span class="kwrd" style="color: red;">Drop failed for Schema &#8216;abc&#8217;.<br />
Cannot drop schema &#8216;abc&#8217; because it is being referenced by object &#8216;Locations&#8217;. (Microsoft SQL Server, Error 3729)</span></div>
<p>In order to fix this issue, we will change the schema of table &#8220;Locations&#8221; to remove the reference. We will use <strong><span style="color: #800000;">sp_changeobjectowner</span></strong> system stored procedure to change schema from abc to dbo. Run below command to change the schema of the table &#8220;Locations&#8221; from abc to dbo.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Change DBName with your database name where user/schema/table exists
--Change the abc to your schema name.</span><span class="kwrd" style="color: blue;">
USE DBName
GO
sp_changeobjectowner 'abc.Locations','dbo'
</span></strong></pre>
<p>Now go ahead and drop the schema post executing above command. This time it will drop without an error.</p>
<pre class="brush: sql; title: ; notranslate" title=""><strong><span class="kwrd" style="color: green;">--Change DBName with your database name where user/schema/table exists
--Change the abc to your schema name which you want to delete.</span><span class="kwrd" style="color: blue;">
USE [DBName]
GO
DROP SCHEMA [abc]
GO
</span></strong></pre>
<p>You can also drop the same using SSMS as well. Go to schema folder inside the security folder of your database. Right click on identified schema and choose delete option.  it will delete your schema.</p>
<p>Learn to fix below errors as well:</p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Error Code 15174: Login Owns one or more databases(s). Change the owner of database(s) before dropping the login.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">Error Code 15173: Revoke the permission(s) before dropping the login.</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="htts://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-15138-error-3729/">Fix SQL Server Error 15138: Dropping User that owned Schema &#038; Error 3729: Schema that referenced to the object</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-15138-error-3729/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
