mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2025-12-13 09:56:01 +00:00
Add error message when mailbox creation fails
This commit is contained in:
@@ -79,7 +79,7 @@ if ($iam_settings['authsource'] != "keycloak" || (intval($iam_settings['periodic
|
|||||||
|
|
||||||
// Set pagination variables
|
// Set pagination variables
|
||||||
$start = 0;
|
$start = 0;
|
||||||
$max = 25;
|
$max = 100;
|
||||||
|
|
||||||
// lock sync if already running
|
// lock sync if already running
|
||||||
$lock_file = '/tmp/iam-sync.lock';
|
$lock_file = '/tmp/iam-sync.lock';
|
||||||
@@ -167,10 +167,12 @@ while (true) {
|
|||||||
$mailcow_template = $user['attributes']['mailcow_template'];
|
$mailcow_template = $user['attributes']['mailcow_template'];
|
||||||
|
|
||||||
// try get mailbox user
|
// try get mailbox user
|
||||||
$stmt = $pdo->prepare("SELECT `mailbox`.* FROM `mailbox`
|
$stmt = $pdo->prepare("SELECT
|
||||||
|
mailbox.*,
|
||||||
|
domain.active AS d_active
|
||||||
|
FROM `mailbox`
|
||||||
INNER JOIN domain on mailbox.domain = domain.domain
|
INNER JOIN domain on mailbox.domain = domain.domain
|
||||||
WHERE `kind` NOT REGEXP 'location|thing|group'
|
WHERE `kind` NOT REGEXP 'location|thing|group'
|
||||||
AND `domain`.`active`='1'
|
|
||||||
AND `username` = :user");
|
AND `username` = :user");
|
||||||
$stmt->execute(array(':user' => $user['email']));
|
$stmt->execute(array(':user' => $user['email']));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@@ -192,13 +194,17 @@ while (true) {
|
|||||||
if (!$row && intval($iam_settings['import_users']) == 1){
|
if (!$row && intval($iam_settings['import_users']) == 1){
|
||||||
// mailbox user does not exist, create...
|
// mailbox user does not exist, create...
|
||||||
logMsg("info", "Creating user " . $user['email']);
|
logMsg("info", "Creating user " . $user['email']);
|
||||||
mailbox('add', 'mailbox_from_template', array(
|
$create_res = mailbox('add', 'mailbox_from_template', array(
|
||||||
'domain' => explode('@', $user['email'])[1],
|
'domain' => explode('@', $user['email'])[1],
|
||||||
'local_part' => explode('@', $user['email'])[0],
|
'local_part' => explode('@', $user['email'])[0],
|
||||||
'name' => $user['firstName'] . " " . $user['lastName'],
|
'name' => $user['firstName'] . " " . $user['lastName'],
|
||||||
'authsource' => 'keycloak',
|
'authsource' => 'keycloak',
|
||||||
'template' => $mbox_template
|
'template' => $mbox_template
|
||||||
));
|
));
|
||||||
|
if (!$create_res){
|
||||||
|
logMsg("err", "Could not create user " . $user['email']);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
} else if ($row && intval($iam_settings['periodic_sync']) == 1) {
|
} else if ($row && intval($iam_settings['periodic_sync']) == 1) {
|
||||||
// mailbox user does exist, sync attribtues...
|
// mailbox user does exist, sync attribtues...
|
||||||
logMsg("info", "Syncing attributes for user " . $user['email']);
|
logMsg("info", "Syncing attributes for user " . $user['email']);
|
||||||
|
|||||||
Reference in New Issue
Block a user