Login failed when using AD credentials from the command line

troyhunttroyhunt Posts: 17 Bronze 3
edited May 22, 2012 4:48AM in SQL Compare Previous Versions
I'm trying to run SQL Compare 10 from the command line to sync a database under source control and a remote DB server as follows:

"C:\Program Files (x86)\Red Gate\SQL Compare 10\SQLCompare.exe" /scr1:[VCS location of DB] /server2:[server name] /db2:[DB name] /Include:identical /Report:Report/SchemaDiffReport.html /ReportType:Interactive /ScriptFile:Report/SchemaSyncScript.sql /Force /Sync /u2:[domain\username] /p2:[password]

Which results in the following:

Registering data sources
Error: Comparison of 'Scripts.Database' and
'[server.database]' failed: Login failed for user
'[domain\username]'.

Can the username and password params accept Active Directory credentials or only SQL logins? I've previously used integrated auth simply by omitting the credentials but in this case I'd really like to use a named AD account - is this feasible?

Comments

  • Sorry, this isn't possible (yet).

    Is there any chance you can try using runas from the command line? Out of interest, what is kicking off the automation? If it's TeamCity, would it be a question of running the agent with a user that has the privileges you need?

    David Atkinson
    Product Manager
    Red Gate
    David Atkinson
    Product Manager
    Redgate Software
  • troyhunttroyhunt Posts: 17 Bronze 3
    Hi David, yes, it's from TeamCity. The problem with using the identity the agent runs under is that any build can then deploy to any location the agent's account has access to. For example, if both project A and project B use the agent's identity to deploy to their DB then there's nothing stopping the owner of project A configuring their deployment target to be the location of project B.

    This is mostly a problem when the build server is used for multiple autonomous projects. Basically the only way you can segregate out access rights is to specify credentials on a per-build basis which is why I wanted to pass these to the command line. It's not a biggie, it just means automation needs to happen using SQL logins instead of AD.

    Thanks for clarifying!
  • Have you tried this using the "runas" command line? Using SQL Server credentials would mean exposing them in cleartext in TeamCity or NAnt scripts, which is generally undesirable.
    David Atkinson
    Product Manager
    Redgate Software
  • troyhunttroyhunt Posts: 17 Bronze 3
    Actually, as of TeamCity 7, passwords can be masked: http://youtrack.jetbrains.com/issue/TW-759

    By adding an environment parameter of type "password" you can include the credentials in the build without disclosing them through any UIs.
  • Nice. I wasn't aware of that.
    David Atkinson
    Product Manager
    Redgate Software
Sign In or Register to comment.