Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

can't create user Expand / Collapse
Author
Message
Posted Thursday, August 27, 2009 2:15 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 09, 2010 7:58 PM
Points: 121, Visits: 195
I have had this problem for years and never bothered to ask about it, but it's causing big problems today.

Moving a database from old server to new. Win2k/SQL2k to Win2003/SQL2005.

I have tables, view and SPs but need to copy users over. Some were already brought over before I started working here. In MSMS, I expand the tree on the left, open Security/Logins. I try to add a new login. When I set everything correctly, I click OK, and it tells me the login already exists. Which is completely false, buy the way. This has happened pretty much 100% of the time I have ever tried to add a login.

So this time, I download the 14-day trial of the Redgate compare tool. It shows the users on the left which don't exist in the new server on the right. I let it generate a script for me. The relevant part for one of them is (the x's are mine):

IF NOT EXISTS (SELECT * FROM master.dbo.syslogins WHERE loginname = N'shipauto')
EXEC sp_addlogin N'shipauto', 'xxxx'
GO
EXEC sp_grantdbaccess N'shipauto', N'shipauto'
GO


I run it, and get this error:

Msg 15023, Level 16, State 1, Line 1
User, group, or role 'shipauto' already exists in the current database.


That statement is completely wrong. I have looked in the list of users, logins, roles, and everywhere else, and it's just completely wrong. This happens every time I try to create a new user, even going back to my SQL 2000/ASP days.
Post #778678
Posted Thursday, August 27, 2009 2:22 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, October 26, 2012 11:23 PM
Points: 91, Visits: 406
Have you checked for the users in the database? Not just the security. Go in that particular database you are trying to give access to that particular user, under security check the users and see if that user is already there?
Post #778683
Posted Thursday, August 27, 2009 2:36 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 09, 2010 7:58 PM
Points: 121, Visits: 195
Yeah, that's what I meant. I checked in both the security section for the desired database and the main security folder.

Having said all that, I just discovered they are in the master database listed under users. Doesn't make any sense. And my programs still don't work.
Post #778704
Posted Thursday, August 27, 2009 2:43 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 09, 2010 7:58 PM
Points: 121, Visits: 195
and just as important, why would redgate generate code that doesn't work?
Post #778715
Posted Thursday, August 27, 2009 3:19 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 6:30 PM
Points: 18,733, Visits: 12,330
A possible reason for the redgate question stems from the users existing in a database. It seems that the users it sees might be orphaned and so it is trying to use the wrong sids. Have you tried to fix orphaned users or remove the users from the master database? It would seem that they should only be in the applicable user databases and not the system databases.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #778757
Posted Thursday, August 27, 2009 3:20 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:24 AM
Points: 5,265, Visits: 11,194
This can happen if you have orphaned users and try to use the GUI, it gets confused. Usually works fine via query window so run all your create logins via a query window using the create login statement.

In the database itself run sp_helpuser or select * from sysusers to see what users are actually defined within the database. those with a NULL in the login column (think its called that) are likely orphaned. Run sp_change_users_login 'report' to confirm this and match them to logins you created to fix them.

If you use sp_help_revlogin (the version designed for SQL2000 to 2005) to transfer your logins these problems should not arise.


---------------------------------------------------------------------

Post #778758
Posted Friday, August 28, 2009 7:47 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 09, 2010 7:58 PM
Points: 121, Visits: 195
A couple of problems with that:

1. The users didn't exist in Master until I ran that script which told me they were already in existence.

2. When I tried to drop them, I got an error saying the user was tied to a schema. I'm afraid to say go ahead and drop the schema at this point.
Post #779098
Posted Friday, August 28, 2009 8:01 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 09, 2010 7:58 PM
Points: 121, Visits: 195
george sibbald (8/27/2009)
This can happen if you have orphaned users and try to use the GUI, it gets confused. Usually works fine via query window so run all your create logins via a query window using the create login statement.


I thought the code pasted in my first post did exactly that.


In the database itself run sp_helpuser or select * from sysusers to see what users are actually defined within the database. those with a NULL in the login column (think its called that) are likely orphaned.


I did and couldn't see any column that might be the one you referred to. The only ones which had a NULL value for some rows in the results set were sid, altuid, and roles.



Run sp_change_users_login 'report' to confirm this and match them to logins you created to fix them.


I ran this and got an empty set, whether I ran it from both the real db and from master.



If you use sp_help_revlogin (the version designed for SQL2000 to 2005) to transfer your logins these problems should not arise.


Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'sp_help_revlogin'.
Post #779115
Posted Friday, August 28, 2009 12:45 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:24 AM
Points: 5,265, Visits: 11,194
sp_help_revlogin -

http://support.microsoft.com/kb/246133

as for NULL value, its the Loginname value returned in sp_helpuser, can point to an orphaned user if its NULL.


---------------------------------------------------------------------

Post #779269
Posted Friday, August 28, 2009 12:49 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 09, 2010 7:58 PM
Points: 121, Visits: 195
as for NULL value, its the Loginname value returned in sp_helpuser, can point to an orphaned user if its NULL.

In which field, though?
Post #779272
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse