mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-10-04 20:16:38 +00:00
realm sync: replace formatted .context() calls
with .map_err/.ok_or_else - since the formatting should not happen in the non-error case Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
750704400a
commit
5f0965edba
@ -1,4 +1,4 @@
|
|||||||
use anyhow::{bail, Context, Error};
|
use anyhow::{bail, format_err, Context, Error};
|
||||||
use pbs_config::{acl::AclTree, token_shadow, BackupLockGuard};
|
use pbs_config::{acl::AclTree, token_shadow, BackupLockGuard};
|
||||||
use proxmox_lang::try_block;
|
use proxmox_lang::try_block;
|
||||||
use proxmox_ldap::{Config, Connection, SearchParameters, SearchResult};
|
use proxmox_ldap::{Config, Connection, SearchParameters, SearchResult};
|
||||||
@ -165,9 +165,11 @@ impl LdapRealmSyncJob {
|
|||||||
let username = result
|
let username = result
|
||||||
.attributes
|
.attributes
|
||||||
.get(user_id_attribute)
|
.get(user_id_attribute)
|
||||||
.context(format!(
|
.ok_or_else(|| {
|
||||||
|
format_err!(
|
||||||
"userid attribute `{user_id_attribute}` not in LDAP search result"
|
"userid attribute `{user_id_attribute}` not in LDAP search result"
|
||||||
))?
|
)
|
||||||
|
})?
|
||||||
.get(0)
|
.get(0)
|
||||||
.context("userid attribute array is empty")?
|
.context("userid attribute array is empty")?
|
||||||
.clone();
|
.clone();
|
||||||
@ -176,7 +178,7 @@ impl LdapRealmSyncJob {
|
|||||||
|
|
||||||
let userid: Userid = username
|
let userid: Userid = username
|
||||||
.parse()
|
.parse()
|
||||||
.context(format!("could not parse username `{username}`"))?;
|
.map_err(|err| format_err!("could not parse username `{username}` - {err}"))?;
|
||||||
retrieved_users.insert(userid.clone());
|
retrieved_users.insert(userid.clone());
|
||||||
|
|
||||||
self.create_or_update_user(user_config, &userid, result)?;
|
self.create_or_update_user(user_config, &userid, result)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user