Changeset View
Changeset View
Standalone View
Standalone View
src/app/Backends/LDAP.php
Show First 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | class LDAP | ||||
* * We certainly don't have its password anymore. | * * We certainly don't have its password anymore. | ||||
* | * | ||||
* 2) The hosted kolab account. | * 2) The hosted kolab account. | ||||
* | * | ||||
* 3) The Directory Manager account. | * 3) The Directory Manager account. | ||||
* | * | ||||
* @param \App\User $user The user account to create. | * @param \App\User $user The user account to create. | ||||
* | * | ||||
* @return void | * @return bool|void | ||||
*/ | */ | ||||
public static function createUser(User $user) | public static function createUser(User $user) | ||||
{ | { | ||||
$config = self::getConfig('admin'); | $config = self::getConfig('admin'); | ||||
$ldap = self::initLDAP($config); | $ldap = self::initLDAP($config); | ||||
list($_local, $_domain) = explode('@', $user->email, 2); | list($_local, $_domain) = explode('@', $user->email, 2); | ||||
Show All 34 Lines | class LDAP | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public static function updateDomain($domain) | public static function updateDomain($domain) | ||||
{ | { | ||||
// | // | ||||
} | } | ||||
public static function deleteDomain($domain) | |||||
{ | |||||
$config = self::getConfig('admin'); | |||||
$ldap = self::initLDAP($config); | |||||
$hosted_root_dn = \config('ldap.hosted.root_dn'); | |||||
$mgmt_root_dn = \config('ldap.admin.root_dn'); | |||||
$domain_base_dn = "ou={$domain->namespace},{$hosted_root_dn}"; | |||||
if ($ldap->get_entry($domain_base_dn)) { | |||||
$ldap->delete_entry_recursive($domain_base_dn); | |||||
} | |||||
if ($ldap_domain = $ldap->find_domain($domain->namespace)) { | |||||
if ($ldap->get_entry($ldap_domain['dn'])) { | |||||
$ldap->delete_entry($ldap_domain['dn']); | |||||
} | |||||
} | |||||
} | |||||
public static function deleteUser($user) | |||||
{ | |||||
$config = self::getConfig('admin'); | |||||
$ldap = self::initLDAP($config); | |||||
list($_local, $_domain) = explode('@', $user->email, 2); | |||||
$domain = $ldap->find_domain($_domain); | |||||
if (!$domain) { | |||||
return false; | |||||
} | |||||
$base_dn = $ldap->domain_root_dn($_domain); | |||||
$dn = "uid={$user->email},ou=People,{$base_dn}"; | |||||
if (!$ldap->get_entry($dn)) { | |||||
return false; | |||||
} | |||||
$ldap->delete_entry($dn); | |||||
} | |||||
/** | /** | ||||
* Update a user in LDAP. | * Update a user in LDAP. | ||||
* | * | ||||
* @param \App\User $user The user account to update. | * @param \App\User $user The user account to update. | ||||
* | * | ||||
* @return void | * @return bool|void | ||||
*/ | */ | ||||
public static function updateUser(User $user) | public static function updateUser(User $user) | ||||
{ | { | ||||
$config = self::getConfig('admin'); | $config = self::getConfig('admin'); | ||||
$ldap = self::initLDAP($config); | $ldap = self::initLDAP($config); | ||||
list($_local, $_domain) = explode('@', $user->email, 2); | list($_local, $_domain) = explode('@', $user->email, 2); | ||||
▲ Show 20 Lines • Show All 140 Lines • Show Last 20 Lines |