Page MenuHomePhorge

D1552.1775157340.diff
No OneTemporary

Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None

D1552.1775157340.diff

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
@@ -98,7 +98,10 @@
$result = $ldap->add_entry($dn, $entry);
if (!$result) {
- self::throwException($ldap, "Failed to create domain {$domain->namespace} in LDAP");
+ self::throwException(
+ $ldap,
+ "Failed to create domain {$domain->namespace} in LDAP (" . __LINE__ . ")"
+ );
}
}
@@ -144,12 +147,19 @@
);
if (!$ldap->get_entry($domainBaseDN)) {
- $ldap->add_entry($domainBaseDN, $entry);
+ $result = $ldap->add_entry($domainBaseDN, $entry);
+
+ if (!$result) {
+ self::throwException(
+ $ldap,
+ "Failed to create domain {$domain->namespace} in LDAP (" . __LINE__ . ")"
+ );
+ }
}
foreach (['Groups', 'People', 'Resources', 'Shared Folders'] as $item) {
if (!$ldap->get_entry("ou={$item},{$domainBaseDN}")) {
- $ldap->add_entry(
+ $result = $ldap->add_entry(
"ou={$item},{$domainBaseDN}",
[
'ou' => $item,
@@ -160,12 +170,19 @@
]
]
);
+
+ if (!$result) {
+ self::throwException(
+ $ldap,
+ "Failed to create domain {$domain->namespace} in LDAP (" . __LINE__ . ")"
+ );
+ }
}
}
foreach (['kolab-admin'] as $item) {
if (!$ldap->get_entry("cn={$item},{$domainBaseDN}")) {
- $ldap->add_entry(
+ $result = $ldap->add_entry(
"cn={$item},{$domainBaseDN}",
[
'cn' => $item,
@@ -179,6 +196,13 @@
]
]
);
+
+ if (!$result) {
+ self::throwException(
+ $ldap,
+ "Failed to create domain {$domain->namespace} in LDAP (" . __LINE__ . ")"
+ );
+ }
}
}
@@ -236,7 +260,10 @@
$result = $ldap->add_entry($dn, $entry);
if (!$result) {
- self::throwException($ldap, "Failed to create user {$user->email} in LDAP");
+ self::throwException(
+ $ldap,
+ "Failed to create user {$user->email} in LDAP (" . __LINE__ . ")"
+ );
}
}
@@ -266,7 +293,10 @@
$result = $ldap->delete_entry_recursive($domainBaseDN);
if (!$result) {
- self::throwException($ldap, "Failed to delete domain {$domain->namespace} from LDAP");
+ self::throwException(
+ $ldap,
+ "Failed to delete domain {$domain->namespace} from LDAP (" . __LINE__ . ")"
+ );
}
}
@@ -275,7 +305,10 @@
$result = $ldap->delete_entry($ldap_domain['dn']);
if (!$result) {
- self::throwException($ldap, "Failed to delete domain {$domain->namespace} from LDAP");
+ self::throwException(
+ $ldap,
+ "Failed to delete domain {$domain->namespace} from LDAP (" . __LINE__ . ")"
+ );
}
}
}
@@ -301,7 +334,10 @@
$result = $ldap->delete_entry($dn);
if (!$result) {
- self::throwException($ldap, "Failed to delete user {$user->email} from LDAP");
+ self::throwException(
+ $ldap,
+ "Failed to delete user {$user->email} from LDAP (" . __LINE__ . ")"
+ );
}
}
@@ -373,7 +409,10 @@
$ldapDomain = $ldap->find_domain($domain->namespace);
if (!$ldapDomain) {
- self::throwException($ldap, "Failed to update domain {$domain->namespace} in LDAP (domain not found)");
+ self::throwException(
+ $ldap,
+ "Failed to update domain {$domain->namespace} in LDAP (domain not found)"
+ );
}
$oldEntry = $ldap->get_entry($ldapDomain['dn']);
@@ -388,7 +427,10 @@
$result = $ldap->modify_entry($ldapDomain['dn'], $oldEntry, $newEntry);
if (!is_array($result)) {
- self::throwException($ldap, "Failed to update domain {$domain->namespace} in LDAP");
+ self::throwException(
+ $ldap,
+ "Failed to update domain {$domain->namespace} in LDAP (" . __LINE__ . ")"
+ );
}
if (empty(self::$ldap)) {
@@ -411,7 +453,10 @@
$newEntry = $oldEntry = self::getUserEntry($ldap, $user->email, $dn, true);
if (!$oldEntry) {
- self::throwException($ldap, "Failed to update user {$user->email} in LDAP (user not found)");
+ self::throwException(
+ $ldap,
+ "Failed to update user {$user->email} in LDAP (user not found)"
+ );
}
self::setUserAttributes($user, $newEntry);
@@ -433,7 +478,10 @@
$result = $ldap->modify_entry($dn, $oldEntry, $newEntry);
if (!is_array($result)) {
- self::throwException($ldap, "Failed to update user {$user->email} in LDAP");
+ self::throwException(
+ $ldap,
+ "Failed to update user {$user->email} in LDAP (" . __LINE__ . ")"
+ );
}
if (empty(self::$ldap)) {
@@ -458,7 +506,10 @@
throw new \Exception("Failed to connect to LDAP");
}
- $bound = $ldap->bind(\config("ldap.{$privilege}.bind_dn"), \config("ldap.{$privilege}.bind_pw"));
+ $bound = $ldap->bind(
+ \config("ldap.{$privilege}.bind_dn"),
+ \config("ldap.{$privilege}.bind_pw")
+ );
if (!$bound) {
throw new \Exception("Failed to bind to LDAP");
diff --git a/src/app/Console/Commands/DomainStatus.php b/src/app/Console/Commands/DomainStatus.php
--- a/src/app/Console/Commands/DomainStatus.php
+++ b/src/app/Console/Commands/DomainStatus.php
@@ -44,6 +44,21 @@
return 1;
}
- $this->info($domain->status);
+ $statuses = [
+ 'active' => Domain::STATUS_ACTIVE,
+ 'suspended' => Domain::STATUS_SUSPENDED,
+ 'deleted' => Domain::STATUS_DELETED,
+ 'ldapReady' => Domain::STATUS_LDAP_READY,
+ 'verified' => Domain::STATUS_VERIFIED,
+ 'confirmed' => Domain::STATUS_CONFIRMED,
+ ];
+
+ foreach ($statuses as $text => $bit) {
+ $func = 'is' . \ucfirst($text);
+
+ $this->info(sprintf("%d %s: %s", $bit, $text, $domain->$func()));
+ }
+
+ $this->info("In total: {$domain->status}");
}
}
diff --git a/src/app/Console/Commands/UserStatus.php b/src/app/Console/Commands/UserStatus.php
--- a/src/app/Console/Commands/UserStatus.php
+++ b/src/app/Console/Commands/UserStatus.php
@@ -44,8 +44,20 @@
return 1;
}
- $this->info("Found user: {$user->id}");
+ $statuses = [
+ 'active' => User::STATUS_ACTIVE,
+ 'suspended' => User::STATUS_SUSPENDED,
+ 'deleted' => User::STATUS_DELETED,
+ 'ldapReady' => User::STATUS_LDAP_READY,
+ 'imapReady' => User::STATUS_IMAP_READY,
+ ];
+
+ foreach ($statuses as $text => $bit) {
+ $func = 'is' . \ucfirst($text);
+
+ $this->info(sprintf("%d %s: %s", $bit, $text, $user->$func()));
+ }
- $this->info($user->status);
+ $this->info("In total: {$user->status}");
}
}

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 2, 7:15 PM (10 h, 16 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18820443
Default Alt Text
D1552.1775157340.diff (7 KB)

Event Timeline