Changeset View
Changeset View
Standalone View
Standalone View
src/app/Backends/LDAP.php
<?php | <?php | ||||
namespace App\Backends; | namespace App\Backends; | ||||
use App\Domain; | use App\Domain; | ||||
use App\Group; | use App\Group; | ||||
use App\User; | use App\User; | ||||
class LDAP | class LDAP | ||||
{ | { | ||||
/** @const array UserSettings used by the backend */ | /** @const array Group settings used by the backend */ | ||||
public const GROUP_SETTINGS = [ | |||||
'sender_policy', | |||||
]; | |||||
/** @const array User settings used by the backend */ | |||||
public const USER_SETTINGS = [ | public const USER_SETTINGS = [ | ||||
'first_name', | 'first_name', | ||||
'last_name', | 'last_name', | ||||
'organization', | 'organization', | ||||
]; | ]; | ||||
/** @var ?\Net_LDAP3 LDAP connection object */ | /** @var ?\Net_LDAP3 LDAP connection object */ | ||||
protected static $ldap; | protected static $ldap; | ||||
▲ Show 20 Lines • Show All 545 Lines • ▼ Show 20 Lines | public static function updateGroup(Group $group): void | ||||
list($cn, $domainName) = explode('@', $group->email); | list($cn, $domainName) = explode('@', $group->email); | ||||
$domain = $group->domain(); | $domain = $group->domain(); | ||||
if (empty($domain)) { | if (empty($domain)) { | ||||
self::throwException( | self::throwException( | ||||
$ldap, | $ldap, | ||||
"Failed to update group {$group->email} in LDAP (" . __LINE__ . ")" | "Failed to update group {$group->email} in LDAP (group not found)" | ||||
); | ); | ||||
} | } | ||||
$hostedRootDN = \config('ldap.hosted.root_dn'); | $hostedRootDN = \config('ldap.hosted.root_dn'); | ||||
$domainBaseDN = "ou={$domain->namespace},{$hostedRootDN}"; | $domainBaseDN = "ou={$domain->namespace},{$hostedRootDN}"; | ||||
$groupBaseDN = "ou=Groups,{$domainBaseDN}"; | $groupBaseDN = "ou=Groups,{$domainBaseDN}"; | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | private static function setDomainAttributes(Domain $domain, array &$entry) | ||||
$entry['inetdomainstatus'] = $domain->status; | $entry['inetdomainstatus'] = $domain->status; | ||||
} | } | ||||
/** | /** | ||||
* Convert group member addresses in to valid entries. | * Convert group member addresses in to valid entries. | ||||
*/ | */ | ||||
private static function setGroupAttributes($ldap, Group $group, &$entry) | private static function setGroupAttributes($ldap, Group $group, &$entry) | ||||
{ | { | ||||
$settings = $group->getSettings(['sender_policy']); | |||||
$entry['kolaballowsmtpsender'] = json_decode($settings['sender_policy'] ?: '[]', true); | |||||
$validMembers = []; | $validMembers = []; | ||||
$domain = $group->domain(); | $domain = $group->domain(); | ||||
$hostedRootDN = \config('ldap.hosted.root_dn'); | $hostedRootDN = \config('ldap.hosted.root_dn'); | ||||
$domainBaseDN = "ou={$domain->namespace},{$hostedRootDN}"; | $domainBaseDN = "ou={$domain->namespace},{$hostedRootDN}"; | ||||
▲ Show 20 Lines • Show All 271 Lines • Show Last 20 Lines |