Skip to content

Commit

Permalink
Support username containing @ for the DDAGENTUSER_NAME
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-lebot committed May 31, 2024
1 parent 366c336 commit 4ca9586
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 4ca9586

Please sign in to comment.