Login failed when using AD credentials from the command line

Compares and synchronizes SQL Server databases, backups and scripts.

Moderators: JonathanWatts, Chris Auckland, David Atkinson, eddie davis, Anu Deshpande, Michelle Taylor, alice.easey, james.billings, chengvoon.tong

Login failed when using AD credentials from the command line

Postby troyhunt » Mon May 21, 2012 4:29 am

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?
troyhunt
 
Posts: 15
Joined: Sun Nov 28, 2010 3:36 am
Location: Australia

Postby David Atkinson » Mon May 21, 2012 5:40 pm

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
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Postby troyhunt » Tue May 22, 2012 7:55 am

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!
troyhunt
 
Posts: 15
Joined: Sun Nov 28, 2010 3:36 am
Location: Australia

Postby David Atkinson » Tue May 22, 2012 8:48 am

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
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase

Postby troyhunt » Tue May 22, 2012 9:34 am

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.
troyhunt
 
Posts: 15
Joined: Sun Nov 28, 2010 3:36 am
Location: Australia

Postby David Atkinson » Tue May 22, 2012 9:48 am

Nice. I wasn't aware of that.
David Atkinson
 
Posts: 1124
Joined: Mon Dec 05, 2005 4:54 pm
Location: Twitter: @dtabase


Return to SQL Compare 10

Who is online

Users browsing this forum: No registered users and 1 guest