From ad56836fce3025545f4f645ac58316d4749cf601 Mon Sep 17 00:00:00 2001 From: "witold.brzozowski" Date: Tue, 22 Oct 2024 14:56:04 +0200 Subject: [PATCH] Ignore escaped commas when parsing active directory DNs --- .../config/ad/ActiveDirectoryUtils.java | 3 ++- .../config/ad/tree/ActiveDirectoryNode.java | 3 ++- .../config/ad/tree/ActiveDirectoryTree.java | 3 ++- .../ActiveDirectoryUserLeaderProvider.java | 4 ++- .../config/ad/ActiveDirectoryUtilsTest.groovy | 27 ++++++++++--------- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/main/java/info/fingo/urlopia/config/ad/ActiveDirectoryUtils.java b/src/main/java/info/fingo/urlopia/config/ad/ActiveDirectoryUtils.java index 4394752..367b83c 100644 --- a/src/main/java/info/fingo/urlopia/config/ad/ActiveDirectoryUtils.java +++ b/src/main/java/info/fingo/urlopia/config/ad/ActiveDirectoryUtils.java @@ -56,7 +56,8 @@ public static String getRelativeDN(String distinguishedName, } public static String getParentDN(String distinguishedName) { - var dnParts = Arrays.stream(distinguishedName.split(",")).toList(); + var commasIgnoringEscapedRegex = "(? getDirectChildrenObjects() { diff --git a/src/main/java/info/fingo/urlopia/config/ad/tree/ActiveDirectoryTree.java b/src/main/java/info/fingo/urlopia/config/ad/tree/ActiveDirectoryTree.java index 706c212..3b832ff 100644 --- a/src/main/java/info/fingo/urlopia/config/ad/tree/ActiveDirectoryTree.java +++ b/src/main/java/info/fingo/urlopia/config/ad/tree/ActiveDirectoryTree.java @@ -48,7 +48,8 @@ private Optional searchNode(String distinguishedName) { if (relativeDn.isBlank()) { return Optional.of(root); } - var dnParts = Arrays.stream(relativeDn.split(",")).toList(); + var commasIgnoringEscapedRegex = "(? extractOrganizationalUnitsDNs(String distinguishedName) { var result = new ArrayList(); - var components = distinguishedName.split(","); + var commasIgnoringEscapedRegex = "(?