xrm-ci-framework icon indicating copy to clipboard operation
xrm-ci-framework copied to clipboard

support for connection strings with client credentials

Open majakubowski opened this issue 5 years ago • 8 comments

majakubowski avatar Apr 03 '19 22:04 majakubowski

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 "=").

lykebank avatar Apr 09 '19 20:04 lykebank

@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

majakubowski avatar Apr 10 '19 06:04 majakubowski

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

lykebank avatar Apr 10 '19 13:04 lykebank

@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!

s-bauer avatar May 21 '19 06:05 s-bauer

Hi @majakubowski @WaelHamze

Is there any plan to release these change and when?

Thanks Sanjay

sanjay1913 avatar Aug 20 '19 15:08 sanjay1913

@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 avatar Sep 16 '19 04:09 WaelHamze

@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.

WaelHamze avatar Jan 15 '20 21:01 WaelHamze

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.

alphonso77 avatar Jan 24 '20 18:01 alphonso77