sqlcmd connection failing unless its a SQL Account!?

  • Hi all,

    So a few months ago i was setting up a AD account for a 3rd party and tested it via sqlcmd everything worked and eventually we got there and got it all working.

    Today i created a new AD account gave it the permissions it needed and when i tried to connect with sqlcmd i get a

    Error: 18456, Severity: 14, State: 5.

    Login failed for user 'NewUser'. Reason: Could not find a login matching the name provided.

    I then tried connecting with my own account that i go via SSMS all the time and that also fails..

    If i try and connect with a SQL account i can get on. But any domain account fails.

    Am i missing something rather silly here or is it some form of evil trick afoot?

    S

  • Please post the whole sqlcmd command that you issued.

    Thanks

    John

  • hi John,

    sqlcmd -S Servername -U newUser -P P@55w0rd

    i read on thread that this only works for SQL accounts and not Windows? but im sure i used if for the previous account. (But maybe im just forgetful in my old age)

    S

  • Check out the syntax by running [font="Courier New"]sqlcmd /?[/font]. I think the switch you need for a trusted connection is /E. Don't forget you must be logged on as that user, or use something like the runas command to impersonate it.

    John

  • Ensure the windows account newUser you are using is explicitly specified as a separate login of type Windows authentication. Theoretically if newUser is a member of a group with connect privilege this should be resolved but I wouldn't trust sqlcmd to resolve a group membership, tbh.

    ---

    Note to developers:
    CAST(SUBSTRING(CAST(FLOOR(NULLIF(ISNULL(COALESCE(1,NULL),NULL),NULL)) AS CHAR(1)),1,1) AS INT) == 1
    So why complicate your code AND MAKE MY JOB HARDER??!:crazy:

    Want to get the best help? Click here https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help (Jeff Moden)
    My blog: http://uksqldba.blogspot.com
    Visit http://www.DerekColley.co.uk to find out more about me.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply