Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Security / January 2008

Tip: Looking for answers? Try searching our database.

Can't login to SQL Server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Klerman Gutierrez - 25 Jan 2008 16:58 GMT
Hello,
I'm trying to migrate one SQL Server 2000 database to SQL Server Express,
and I'm having the following issue.
In the SQL Server 2000 database I have two users A and B. User A belongs to
the sysadmin server fixed role, and user B belongs to the db_datareader and
db_datawriter database roles.
In SQL Server 2000, all works as expected, but in SQL Express I can't login
with the user B to the SQL Server.
The SQL Server Express database is in a Windows Vista machine, and the
security mode is SQL authentication.
Can you point me to the solution of this problem ?
TVMIA,
Klerman Gutierrez
Erland Sommarskog - 25 Jan 2008 22:37 GMT
> I'm trying to migrate one SQL Server 2000 database to SQL Server Express,
> and I'm having the following issue.
[quoted text clipped - 6 lines]
> security mode is SQL authentication.
> Can you point me to the solution of this problem ?

Are A and B SQL logins or Windows logins?

Do you connect locally, or from a remote machine?

How you connect? From the application? From a query tool?

What error message do you get?

How did you perform the migration? Did you upgrade the entire instance,
or did just move the database with backup/restore, dettach/attach or
used the Copy Database Wizard? If you only copied the database, did
you also add the logins to the SQL 2005 instance, and remapped the
users after the move?

Signature

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Klerman Gutierrez - 25 Jan 2008 23:28 GMT
Erland,

I did a backup in SQL Server 2000 and restored it in SQL Server Express SP2.
Once restored the database, I ran a stored procedure in SQL Server Express
that creates those users for me since SQL Server 2000 times.
To connect to the database I'm using SQLCMD from the Vista server and with
OSQL from a W2000 workstation.
I can connect to the database with the SA user and with the user A which
belongs to the sysadmin role. The data seems to be fine as I can execute
SELECTs.
But with the user B, that only belongs to the db_datareader and
db_datawriter roles I receive the message (I'll translate from spanish not
literally): "Message 18456. Login error for user B".
I inspected the SQL tables and found that user B is a SQL login, and also a
database user.

Sincerely
Klerman Gutierrez
Klerman Gutierrez - 25 Jan 2008 23:41 GMT
The SQL than I'm using is this:

exec sp_addlogin 'USERA', 'xxxxx', 'MyDatabase'
exec sp_addsrvrolemember 'USERA', sysadmin
exec sp_addlogin 'USERB', 'xxxxxx', 'MyDatabase'
EXEC sp_grantdbaccess 'USERB'
EXEC sp_addrolemember db_datareader, 'USERB'
EXEC sp_addrolemember db_datawriter, 'USERB'
Erland Sommarskog - 26 Jan 2008 17:35 GMT
> The SQL than I'm using is this:
>
[quoted text clipped - 4 lines]
> EXEC sp_addrolemember db_datareader, 'USERB'
> EXEC sp_addrolemember db_datawriter, 'USERB'

Have you checked the output from this script? From your description I
would expect this command to fail:

  EXEC sp_grantdbaccess 'USERB'

There is already a USERB in the database per your description. The
database user is part of the database, so it was included when you copied
the database.

What you need to do is to connect the existing database user USERB
with the newly created login USERB. (The logins are stored in master,
so the login USERB was not included in the copy operation.) You can
do this with the command:

  ALTER USER USERB WITH LOGIN = USERB

If this gives you a syntax error, it is because you have not applied SP2
of SQL 2005, which you should do.

There is one more thing you need to be aware of: in SQL 2005, passwords
are always case-sensitive. So if the script says:

 exec sp_addlogin 'USERB', 'TopSecret', 'MyDatabase'

and you try to log in with "topsecret" that will fail.

Finally, while the above commands work on SQL 2005, SQL 2005 now has
proper commands to create logins and user, CREATE LOGIN and CREATE USER.
There are no commands for adding users to roles though.

Signature

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Klerman Gutierrez - 26 Jan 2008 21:23 GMT
It was due to the password. In the script I created the password in
capitals. I didn't know that SQL Server Express was case sensitive. Now I
can connect with the server with either two of the users.

Thank you very much for the help, I was really stopped by this.

Best regards,

Klerman Gutierrez
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.