]> git.proxmox.com Git - proxmox.git/commitdiff
ldap: avoid superfluous allocation when calling .search()
authorChristoph Heiss <c.heiss@proxmox.com>
Fri, 12 Jan 2024 16:15:56 +0000 (17:15 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 25 Mar 2024 16:03:27 +0000 (17:03 +0100)
The `attrs` parameter of `Ldap::search()` is an `impl AsRef<[impl
AsRef<str>]>` anyway, so replace `vec![..]` with `&[..]`.

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
proxmox-ldap/src/lib.rs

index b3b5d65f70167d5d09ba1989a19a662d76f6402e..f9862e2ab3ad63ed70671169b3418203f406f46a 100644 (file)
@@ -181,12 +181,7 @@ impl Connection {
 
         // only search base to make sure the base_dn exists while avoiding most common size limits
         let (_, _) = ldap
-            .search(
-                &self.config.base_dn,
-                Scope::Base,
-                "(objectClass=*)",
-                vec!["*"],
-            )
+            .search(&self.config.base_dn, Scope::Base, "(objectClass=*)", &["*"])
             .await?
             .success()
             .context("Could not search LDAP realm, base_dn could be incorrect")?;
@@ -319,7 +314,7 @@ impl Connection {
         let query = format!("(&({}={}))", self.config.user_attr, username);
 
         let (entries, _res) = ldap
-            .search(&self.config.base_dn, Scope::Subtree, &query, vec!["dn"])
+            .search(&self.config.base_dn, Scope::Subtree, &query, &["dn"])
             .await?
             .success()?;