WaelHamze / xrm-ci-framework

xRM CI Framework provides you with the tools automate the build and deployment of your CRM Solution. Using the framework to implement a fully automated DevOps pipeline will allow you to deploy more frequently with added consistency and quality.
MIT License
186 stars 117 forks source link

support for connection strings with client credentials #205

Open majakubowski opened 5 years ago

lykebank commented 5 years ago

I'm looking to leverage a S2S connection as well and you're a couple steps ahead of me. However, your method for parsing the ClientSecret from a custom connection string does not account for client secrets that may include special characters (e.g. ";" or "=").

majakubowski commented 5 years ago

@lykebank but the same goes for "standard" passwords :) Special characters are not a problem.. example:

var connectionString = "AuthType=s2s; ClientId=some-guid; ClientSecret=' {!\"$% &/ () =?`*''_:;}'; Url=https://orgxx.crm4.dynamics.com";
var parsedConnectionString = connectionString.ToDictionary();
Console.WriteLine("Parsed connection string:");
foreach (var pair in parsedConnectionString)
{
    Console.WriteLine($"{pair.Key} = `{pair.Value}`");
}

returns:

Parsed connection string:
authtype = `s2s`
clientid = `some-guid`
clientsecret = ` {!"$% &/ () =?`*'_:;}`
url = `https://orgxx.crm4.dynamics.com`

reference: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms722656(v=vs.85)#setting-values-that-use-reserved-characters

ps: ToDictionary is not standard LINQ extenstion method.. but defined in Microsoft.Xrm.Tooling.Connector

lykebank commented 5 years ago

OK works for me, then. I've just been in the bad habit of not enclosing password values in quote characters.

s-bauer commented 5 years ago

@WaelHamze What's your opinion on this? I'm in need of supporting client credentials in the MSCRM Build Tool Extension for Azure DevOps. I could help out adding it if you don't have any objections!

sanjay1913 commented 5 years ago

Hi @majakubowski @WaelHamze

Is there any plan to release these change and when?

Thanks Sanjay

WaelHamze commented 5 years ago

@majakubowski @s-bauer @sanjay1913 thank for submitting this PR. I think this is a great idea. However MS recently added support for client secrets: https://www.nuget.org/packages/Microsoft.CrmSdk.XrmTooling.CoreAssembly/

I think this would meet your needs right?

WaelHamze commented 4 years ago

@majakubowski great work but this is now OOB. Let me know if there is anything from this PR that you would still like to add.

alphonso77 commented 4 years ago

I'm not sure if it's applicable, but I'm having an issue with a connectionstring that contains special characters in the password; attempting to run Select-WhoAmI -ConnectionString $connectionString from PS script; it works when the connection string uses a password without special characters.