Skip to content

Commit caeb62c

Browse files
authored
Merge pull request #608 from bonroyage/2.x/case-insensitive-dn-comparison
[2.x] Case insensitive DN comparison
2 parents 00d04ee + af0f5ef commit caeb62c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Models/Collection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ protected function compareModelWithRelated($model, $related)
109109
{
110110
if (is_string($model)) {
111111
return $this->isValidDn($model)
112-
? $related->getDn() == $model
113-
: $related->getName() == $model;
112+
? strcasecmp($related->getDn(), $model) === 0
113+
: strcasecmp($related->getName(), $model) === 0;
114114
}
115115

116116
return $related->is($model);

tests/Unit/Models/ModelRelationTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,13 @@ public function test_exists()
128128
$this->assertTrue($relation->exists($related->newCollection([$related])));
129129
$this->assertTrue($relation->exists('foo'));
130130
$this->assertTrue($relation->exists('cn=foo,dc=local,dc=com'));
131+
$this->assertTrue($relation->exists('CN=foo,DC=local,DC=com'));
131132

132133
$this->assertFalse($relation->exists(null));
133134
$this->assertFalse($relation->exists($unrelated->newCollection([$unrelated])));
134135
$this->assertFalse($relation->exists([$related, $unrelated]));
135136
$this->assertFalse($relation->exists(['cn=foo,dc=local,dc=com', 'cn=bar,dc=local,dc=com']));
137+
$this->assertFalse($relation->exists(['CN=foo,DC=local,DC=com', 'CN=bar,DC=local,DC=com']));
136138
$this->assertFalse($relation->exists('bar'));
137139
}
138140

0 commit comments

Comments
 (0)