2

I'm trying to follow the procedures described in this link here but if I enter IIS APPPOOL\AppPoolName as the login name (as in step 3) it throws an error saying that it is not a valid name because it contains invalid characters. I'm using SSMS for SQL 2012.

UPDATE: Just to clarify: The "Invalid character" error was b/c I was trying to enter the user on "SQL Server Authentication" when it must be "Windows Authentication".

Community
  • 1
  • 1
Ben Junior
  • 2,449
  • 10
  • 34
  • 51

3 Answers3

3

Ben answered his own question:

UPDATE: Just to clarify: The "Invalid character" error was b/c I was trying to enter the user on "SQL Server Authentication" when it must be "Windows Authentication".

Dunc
  • 18,404
  • 6
  • 86
  • 103
2

here is some sample TSQL code from one of my blogs to create a login and user. http://craftydba.com/?p=656

It does not like the . Put in in brackets. []

-- Delete existing login.
IF  EXISTS (SELECT * FROM sys.server_principals WHERE name = N'BSA_USER')
DROP LOGIN [BSA_USER]
GO

-- Add new login.
CREATE LOGIN [BSA_USER] WITH PASSWORD=N'M0a2r0c9h11#', DEFAULT_DATABASE=[BSA]
GO

-- Delete existing user.
IF  EXISTS (SELECT * FROM sys.database_principals WHERE name = N'BSA_USER')
DROP USER [BSA_USER]
GO

-- Add new user.
CREATE USER [BSA_USER] FOR LOGIN [BSA_USER] WITH DEFAULT_SCHEMA=[dbo]
GO

Change the syntax for a Windows Account.

-- Using users naming ...
CREATE LOGIN [APPPOOL\MyAppPool]
FROM WINDOWS
WITH DEFAULT_DATABASE = [MyDatabase]
GO
CRAFTY DBA
  • 14,351
  • 4
  • 26
  • 30
  • Thanks for your reply. Here is the msg after I executed your script: Msg 15006, Level 16, State 1, Line 2 'IIS APPPOOL\MyAppPool' is not a valid name because it contains invalid characters. – Ben Junior Jul 09 '14 at 17:46
  • Please see above, if windows account, add FROM WINDOWS. I gave you a code snippet above, Please try again. – CRAFTY DBA Jul 09 '14 at 18:01
  • I got his error : Windows NT user or group 'LAPTOP-N48A3H8V\AspNetCore' not found. Check the name again. – Sankar Mar 26 '17 at 12:24
2

I had the same problem when creating a Windows domain user in SSMS.

This solved it:

https://social.msdn.microsoft.com/Forums/en-US/8f084029-b0cf-4e7d-bb07-a11e31363660/tsd03072-xxxxxxx-is-not-a-valid-name-because-it-contains-invalid-characters?forum=vstsdb

Synopsis: The error message is misleading, the error case is that the for the situation where you have a Windows login and the (userName != loginName). The code does not take casing into consideration right now, so they have to be an exact match.

Onur
  • 5,017
  • 5
  • 38
  • 54