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

Create login - domain name with '.' Expand / Collapse
Author
Message
Posted Wednesday, September 19, 2012 3:14 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, November 29, 2012 4:13 PM
Points: 2, Visits: 10
Hi
I'm trying to create a simple script to allow Network Service accout to access my database

DECLARE @user NVARCHAR(50)
SET @user = ABC.COM\ABC105$'

DECLARE @SQL NVARCHAR(4000);

SET @SQL = 'CREATE LOGIN [' + @user + '] FROM WINDOWS WITH DEFAULT_DATABASE=[master]'
EXECUTE(@SQL);

SET @SQL = 'CREATE USER [' + @user + '] FOR LOGIN ['+@user+'] WITH DEFAULT_SCHEMA=[dbo]'
EXECUTE(@SQL);

EXEC sp_addrolemember 'db_owner', @user
GO

The script fails with the message:
Msg 15401, Level 16, State 1, Line 1
Windows NT user or group 'ABC.COM\ABC105$' not found. Check the name again.

if I just execute
CREATE LOGIN ABC.COM\ABC105$ FROM WINDOWS WITH DEFAULT_DATABASE=[master]
it says
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '.'.

How do I fix that?

Thanks in advance
Post #1361646
Posted Wednesday, September 19, 2012 3:32 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, November 29, 2012 4:13 PM
Points: 2, Visits: 10
Hmmm I figured it out myself. The domain should not include the .com portion. Not clear why though
Post #1361662
Posted Wednesday, September 19, 2012 11:03 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 12:36 PM
Points: 3,466, Visits: 1,813
Just out of curiosity give this a try:

CREATE LOGIN [ABC.COM]\ABC105$ FROM WINDOWS WITH DEFAULT_DATABASE=[master]



Kenneth Fisher
I strive to live in a world where a chicken can cross the road without being questioned about its motives.
--------------------------------------------------------------------------------
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Link to my Blog Post --> www.SQLStudies.com
Post #1361732
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse