SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Create login - domain name with '.'


Create login - domain name with '.'

Author
Message
victorel
victorel
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
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
victorel
victorel
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 10
Hmmm I figured it out myself. The domain should not include the .com portion. Not clear why though
Kenneth Fisher
Kenneth Fisher
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6307 Visits: 2059
Just out of curiosity give this a try:

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

Kenneth FisherI 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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search