﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Timothy Ford  / Fixing Orphaned Users / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 03:16:09 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>Nice article:)I It's mentioned that orphaned users do no exist in Windows logins, This is true for the same domain, but if you restore the database to another domain, I believe it's not.</description><pubDate>Fri, 07 Dec 2007 13:35:10 GMT</pubDate><dc:creator>Hesham A. Amin</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>I also have similar problem. Step 1. Create the file get_users_login.sql select 'exec sp_change_users_login ' + quotename('Update_One', char(39)) + ',' +  quotename(sl.name, char(39)) + ',' + quotename(su.name, char(39)) + ';'from master.dbo.syslogins sljoin dbo.sysusers su on sl.sid = su.sid where sl.hasaccess = 1 and sl.isntname = 0 and sl.name not in ('guest', 'dbo', 'sys', 'INFORMATION_SCHEMA')Step 2.osql get_users_login.sql -o fix_users_login.sql -w 2048 -n -h-1Step 3.Run osql fix_users_login.sql against any other server</description><pubDate>Thu, 06 Dec 2007 13:52:12 GMT</pubDate><dc:creator>Dmitriy Burtsev</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>I used to use sp_update_user_logins all the time, but with 80+ servers and almost 1,000 databases that I support without aid of a Jr. DBA I had to abandon that for something more automated and global across multiple logins at one time.  It is a great stored proc though.</description><pubDate>Wed, 05 Dec 2007 08:05:35 GMT</pubDate><dc:creator>Timothy Ford-473880</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>[quote][b]ThomasLL (12/4/2007)[/b][hr]What is the difference between Auto_Fix and Update_One?ThomasLL[/quote]AUTO_FIX matches based on the user alias in the DB to a login account.UPDATE_ONE allows you to specify the alias mapping to the login account.See BOL for more detail if needs be.</description><pubDate>Wed, 05 Dec 2007 07:35:01 GMT</pubDate><dc:creator>Antares686</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>What is the difference between Auto_Fix and Update_One?ThomasLL</description><pubDate>Tue, 04 Dec 2007 15:43:33 GMT</pubDate><dc:creator>Thomas LeBlanc</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>This is what I personally useselect 'exec sp_change_users_login ''AUTO_FIX'',''' + [name] + '''', * from sysusers where status != 0 and uid &amp;gt; 2it builds a string for each account, then I take and run the resultset in another &amp;#119;indow.</description><pubDate>Tue, 04 Dec 2007 10:33:30 GMT</pubDate><dc:creator>Antares686</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>Great article Tim.  Thanks.  You said:[quote]You can add the login to the SQL instance and re-run the script thereby reconciling the user and login.[/quote]  Since you are discussing moving from test to production would it not be better to scan for missing logins and removed those users by default?  The thinking is more restriction is better so if the login does not exist on the server you can't [b]grant[/b] permissions.I have the same challenge in the opposite direction.  I pull production databases and restore to our development servers.  I had this problem in SQL 2000 but I found an odd work-around.  If I stop and restart the service SQL seems to relink my logins by itself. :)</description><pubDate>Tue, 04 Dec 2007 09:57:03 GMT</pubDate><dc:creator>Charles Kincaid</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>sp_helprevlogin is the procedure, but it's a 2005 one only now. They updated it. The original for 7/2000 is available in the script library here.http://www.sqlservercentral.com/scripts/Maintenance+and+Management/31711/Nice article, Tim!</description><pubDate>Tue, 04 Dec 2007 07:45:51 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>I agree that sync'ing SID's is a pretty good idea. MS also has a script up on MSDN that will script out all your logins along with the encrypted passwords so you can just run it against the other server and be done.</description><pubDate>Tue, 04 Dec 2007 06:54:11 GMT</pubDate><dc:creator>Andy Warren</dc:creator></item><item><title>RE: Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>I agree that this can be an issue but you can help yourself out a little by reviewing the syntax of the "CREATE LOGIN" or "sp_addlogin" commands.Both of these commands allow you to specify the SID.  If you are able to specify the same SID for the logins on each of the servers, you can happily backup/restore databases between instances and the login and user entries will match because you created the login on each instance with the same SID.This is especially important when you are using log shipping or database mirroring.  When a problem occurs and your primary server dies, there is one less issue that needs to be handled to get your standby database online.  In the case of mirroring, ensuring that you use the same SID allows you to automatically bring the mirroring online with no intervention required.</description><pubDate>Mon, 03 Dec 2007 21:35:30 GMT</pubDate><dc:creator>happycat59</dc:creator></item><item><title>Fixing Orphaned Users</title><link>http://www.sqlservercentral.com/Forums/Topic429094-1147-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/articles/Administration/61648/"&gt;Fixing Orphaned Users&lt;/A&gt;[/B]</description><pubDate>Mon, 03 Dec 2007 21:27:24 GMT</pubDate><dc:creator>Timothy Ford-473880</dc:creator></item></channel></rss>