diff --git a/tools/windows/DatadogAgentInstaller/CustomActions.Tests/ProcessUserCustomActions/ProcessUserCustomActionsDomainClientTests.cs b/tools/windows/DatadogAgentInstaller/CustomActions.Tests/ProcessUserCustomActions/ProcessUserCustomActionsDomainClientTests.cs index 0f39fd84b1bc3..05f506c8c5e5f 100644 --- a/tools/windows/DatadogAgentInstaller/CustomActions.Tests/ProcessUserCustomActions/ProcessUserCustomActionsDomainClientTests.cs +++ b/tools/windows/DatadogAgentInstaller/CustomActions.Tests/ProcessUserCustomActions/ProcessUserCustomActionsDomainClientTests.cs @@ -70,7 +70,7 @@ public void ProcessDdAgentUserCredentials_Succeeds_With_Custom_Existing_Domain_U Test.WithDomainUser(ddAgentUserName); Test.Session - .Setup(session => session["DDAGENTUSER_NAME"]).Returns($"{Domain}\\{ddAgentUserName}"); + .Setup(session => session["DDAGENTUSER_NAME"]).Returns($"{Domain}@{ddAgentUserName}"); Test.Session .Setup(session => session["DDAGENTUSER_PASSWORD"]).Returns(ddAgentUserPassword); diff --git a/tools/windows/DatadogAgentInstaller/CustomActions/ProcessUserCustomActions.cs b/tools/windows/DatadogAgentInstaller/CustomActions/ProcessUserCustomActions.cs index 090e8cc92b0c0..6e3263cc3b17f 100644 --- a/tools/windows/DatadogAgentInstaller/CustomActions/ProcessUserCustomActions.cs +++ b/tools/windows/DatadogAgentInstaller/CustomActions/ProcessUserCustomActions.cs @@ -1,5 +1,6 @@ using System; using System.DirectoryServices.ActiveDirectory; +using System.Linq; using System.Security.Cryptography; using System.Security.Principal; using System.Windows.Forms; @@ -170,9 +171,9 @@ private void ParseUserName(string account, out string userName, out string domai // We do not use CredUIParseUserName because it does not handle some cases nicely. // e.g. CredUIParseUserName(host.ddev.net\user) returns userName=.ddev.net domain=host.ddev.net // e.g. CredUIParseUserName(.\user) returns userName=.\user domain= - if (account.Contains("\\")) + var sepChars = new[] { '\\', '@' }; + foreach (var parts in sepChars.Where(account.Contains).Select(s => account.Split(s))) { - var parts = account.Split('\\'); domain = parts[0]; userName = parts[1]; if (NameUsesDefaultPart(domain))