-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Ldap] Incorrect determination of RelativeDistinguishedName for the "move" operation #39518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,34 @@ public function testGetResources() | |
$entryManager = new EntryManager($connection); | ||
$entryManager->update($entry); | ||
} | ||
|
||
/** | ||
* @see https://tools.ietf.org/html/rfc4514#section-3 | ||
* | ||
* @dataProvider moveWithRFC4514DistinguishedNameProvider | ||
*/ | ||
public function testMoveWithRFC4514DistinguishedName(string $dn, string $expectedRdn) | ||
{ | ||
$connection = $this->createMock(Connection::class); | ||
|
||
$entry = new Entry($dn); | ||
$entryManager = new EntryManager($connection); | ||
|
||
$method = (new \ReflectionClass(EntryManager::class))->getMethod('parseRdnFromEntry'); | ||
$method->setAccessible(true); | ||
|
||
$cn = $method->invokeArgs($entryManager, [$entry, 'a']); | ||
|
||
$this->assertSame($expectedRdn, $cn); | ||
} | ||
|
||
public function moveWithRFC4514DistinguishedNameProvider(): array | ||
astepin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
return [ | ||
['CN=Simple,DC=example,DC=net', 'CN=Simple'], | ||
['CN=James \"Jim\" Smith\, III,DC=example,DC=net', 'CN=James \"Jim\" Smith\, III'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry if it's a dumb question: should the expected value be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Certain characters in the canonical name must be escaped for them to work with LDAP server. So to continue working with the LDAP server we need the backslash in front of the quotes. => |
||
['UID=jsmith,DC=example,DC=net', 'UID=jsmith'], | ||
["CN=Before\0dAfter,DC=example,DC=net", "CN=Before\0dAfter"], | ||
]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the regexp won't work when several
\
are used, eg with\\\\
or\\\\\,
,isn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of
\
shouldn't matter. Compared to the old code, basically the same is done, except that now the comma is not matched if it is escaped with a\
.It's a bit tricky with the "not matching regex groups" (starting with ?: ). It is quite hard to read and understand.