Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117849933
D1678.1775313306.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D1678.1775313306.diff
View Options
diff --git a/src/app/Backends/LDAP.php b/src/app/Backends/LDAP.php
--- a/src/app/Backends/LDAP.php
+++ b/src/app/Backends/LDAP.php
@@ -230,7 +230,11 @@
'nsroledn' => []
];
- if (!self::getUserEntry($ldap, $user->email, $dn) && $dn) {
+ if (!self::getUserEntry($ldap, $user->email, $dn)) {
+ if (empty($dn)) {
+ self::throwException($ldap, "Failed to create user {$user->email} in LDAP");
+ }
+
self::setUserAttributes($user, $entry);
$result = $ldap->add_entry($dn, $entry);
diff --git a/src/tests/Feature/Backends/LDAPTest.php b/src/tests/Feature/Backends/LDAPTest.php
--- a/src/tests/Feature/Backends/LDAPTest.php
+++ b/src/tests/Feature/Backends/LDAPTest.php
@@ -222,6 +222,24 @@
}
/**
+ * Test handling errors on user creation
+ *
+ * @group ldap
+ */
+ public function testCreateUserException(): void
+ {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageMatches('/Failed to create user/');
+
+ $user = new User([
+ 'email' => 'test-non-existing-ldap@non-existing.org',
+ 'status' => User::STATUS_ACTIVE,
+ ]);
+
+ LDAP::createUser($user);
+ }
+
+ /**
* Test handling update of a non-existing domain
*
* @group ldap
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 4, 2:35 PM (15 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18829965
Default Alt Text
D1678.1775313306.diff (1 KB)
Attached To
Mode
D1678: Correctly handle "non-existing domain" in LDAP::createUser()
Attached
Detach File
Event Timeline