pub struct LdapConfig {Show 19 fields
pub url: String,
pub base_dn: String,
pub user_search_base: String,
pub user_search_filter: String,
pub group_search_base: String,
pub group_search_filter: String,
pub group_role_attribute: String,
pub bind_dn: Option<String>,
pub bind_password: Option<String>,
pub user_dn_pattern: Option<String>,
pub connect_timeout: Duration,
pub operation_timeout: Duration,
pub use_starttls: bool,
pub role_prefix: String,
pub convert_to_uppercase: bool,
pub username_attribute: String,
pub email_attribute: String,
pub display_name_attribute: String,
pub attribute_mappings: HashMap<String, String>,
}Expand description
LDAP connection configuration.
Fields§
§url: StringLDAP server URL (e.g., “ldap://localhost:389” or “ldaps://localhost:636”)
base_dn: StringBase DN for searches (e.g., “dc=example,dc=com”)
user_search_base: StringUser search base (relative to base_dn)
user_search_filter: StringUser search filter (use {0} for username placeholder)
group_search_base: StringGroup search base (relative to base_dn)
group_search_filter: StringGroup search filter (use {0} for user DN placeholder)
group_role_attribute: StringGroup role attribute (e.g., “cn”)
bind_dn: Option<String>Bind DN for searching (optional, for bind-then-search)
bind_password: Option<String>Bind password
user_dn_pattern: Option<String>User DN pattern for direct bind (use {0} for username)
connect_timeout: DurationConnection timeout
operation_timeout: DurationOperation timeout
use_starttls: boolUse StartTLS
role_prefix: StringRole prefix (e.g., “ROLE_”)
convert_to_uppercase: boolConvert roles to uppercase
username_attribute: StringUsername attribute in LDAP
email_attribute: StringEmail attribute in LDAP
display_name_attribute: StringDisplay name attribute in LDAP
attribute_mappings: HashMap<String, String>Custom attribute mappings
Implementations§
Source§impl LdapConfig
impl LdapConfig
Sourcepub fn new(url: impl Into<String>) -> LdapConfig
pub fn new(url: impl Into<String>) -> LdapConfig
Create a new LDAP configuration with the server URL.
Sourcepub fn active_directory(
url: impl Into<String>,
domain: impl Into<String>,
) -> LdapConfig
pub fn active_directory( url: impl Into<String>, domain: impl Into<String>, ) -> LdapConfig
Create configuration for Active Directory.
Sourcepub fn base_dn(self, dn: impl Into<String>) -> LdapConfig
pub fn base_dn(self, dn: impl Into<String>) -> LdapConfig
Set the base DN.
Sourcepub fn user_search_base(self, base: impl Into<String>) -> LdapConfig
pub fn user_search_base(self, base: impl Into<String>) -> LdapConfig
Set the user search base (relative to base DN).
Sourcepub fn user_search_filter(self, filter: impl Into<String>) -> LdapConfig
pub fn user_search_filter(self, filter: impl Into<String>) -> LdapConfig
Set the user search filter.
Sourcepub fn group_search_base(self, base: impl Into<String>) -> LdapConfig
pub fn group_search_base(self, base: impl Into<String>) -> LdapConfig
Set the group search base (relative to base DN).
Sourcepub fn group_search_filter(self, filter: impl Into<String>) -> LdapConfig
pub fn group_search_filter(self, filter: impl Into<String>) -> LdapConfig
Set the group search filter.
Sourcepub fn bind_dn(self, dn: impl Into<String>) -> LdapConfig
pub fn bind_dn(self, dn: impl Into<String>) -> LdapConfig
Set the bind DN for searching.
Sourcepub fn bind_password(self, password: impl Into<String>) -> LdapConfig
pub fn bind_password(self, password: impl Into<String>) -> LdapConfig
Set the bind password.
Sourcepub fn user_dn_pattern(self, pattern: impl Into<String>) -> LdapConfig
pub fn user_dn_pattern(self, pattern: impl Into<String>) -> LdapConfig
Set the user DN pattern for direct bind authentication.
Sourcepub fn connect_timeout(self, timeout: Duration) -> LdapConfig
pub fn connect_timeout(self, timeout: Duration) -> LdapConfig
Set connection timeout.
Sourcepub fn operation_timeout(self, timeout: Duration) -> LdapConfig
pub fn operation_timeout(self, timeout: Duration) -> LdapConfig
Set operation timeout.
Sourcepub fn use_starttls(self, use_tls: bool) -> LdapConfig
pub fn use_starttls(self, use_tls: bool) -> LdapConfig
Enable StartTLS.
Sourcepub fn role_prefix(self, prefix: impl Into<String>) -> LdapConfig
pub fn role_prefix(self, prefix: impl Into<String>) -> LdapConfig
Set the role prefix.
Sourcepub fn convert_to_uppercase(self, convert: bool) -> LdapConfig
pub fn convert_to_uppercase(self, convert: bool) -> LdapConfig
Set whether to convert roles to uppercase.
Sourcepub fn map_attribute(
self,
ldap_attr: impl Into<String>,
user_attr: impl Into<String>,
) -> LdapConfig
pub fn map_attribute( self, ldap_attr: impl Into<String>, user_attr: impl Into<String>, ) -> LdapConfig
Add a custom attribute mapping.
Sourcepub fn full_user_search_base(&self) -> String
pub fn full_user_search_base(&self) -> String
Get the full user search base DN.
Sourcepub fn full_group_search_base(&self) -> String
pub fn full_group_search_base(&self) -> String
Get the full group search base DN.
Sourcepub fn build_user_filter(&self, username: &str) -> String
pub fn build_user_filter(&self, username: &str) -> String
Build the user search filter with username substituted.
Sourcepub fn build_group_filter(&self, user_dn: &str) -> String
pub fn build_group_filter(&self, user_dn: &str) -> String
Build the group search filter with user DN substituted.
Sourcepub fn build_user_dn(&self, username: &str) -> Option<String>
pub fn build_user_dn(&self, username: &str) -> Option<String>
Build the user DN from pattern.
Trait Implementations§
Source§impl Clone for LdapConfig
impl Clone for LdapConfig
Source§fn clone(&self) -> LdapConfig
fn clone(&self) -> LdapConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LdapConfig
impl Debug for LdapConfig
Source§impl Default for LdapConfig
impl Default for LdapConfig
Source§fn default() -> LdapConfig
fn default() -> LdapConfig
Auto Trait Implementations§
impl Freeze for LdapConfig
impl RefUnwindSafe for LdapConfig
impl Send for LdapConfig
impl Sync for LdapConfig
impl Unpin for LdapConfig
impl UnwindSafe for LdapConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more