pub struct Username { /* private fields */ }Expand description
A username formatted as either UPN or Down-Level Logon Name
Implementations§
Source§impl Username
impl Username
Sourcepub fn new_upn(
account_name: &str,
upn_suffix: &str,
) -> Result<Self, UsernameError>
pub fn new_upn( account_name: &str, upn_suffix: &str, ) -> Result<Self, UsernameError>
Builds a user principal name from an account name and an UPN suffix
Sourcepub fn new_down_level_logon_name(
account_name: &str,
netbios_domain_name: &str,
) -> Result<Self, UsernameError>
pub fn new_down_level_logon_name( account_name: &str, netbios_domain_name: &str, ) -> Result<Self, UsernameError>
Builds a down-level logon name from an account name and a NetBIOS domain name
Sourcepub fn new(
account_name: &str,
netbios_domain_name: Option<&str>,
) -> Result<Self, UsernameError>
pub fn new( account_name: &str, netbios_domain_name: Option<&str>, ) -> Result<Self, UsernameError>
Attempts to guess the right name format for the account name/domain combo
If no netbios domain name is provided, or if it is an empty string, the username will be parsed as either a user principal name or a down-level logon name.
It falls back to a down-level logon name when the format can’t be guessed.
Sourcepub fn parse(value: &str) -> Result<Self, UsernameError>
pub fn parse(value: &str) -> Result<Self, UsernameError>
Parses the value in order to find if the value is a user principal name or a down-level logon name
If there is no \ or @ separator, the value is considered to be a down-level logon name with
an empty NetBIOS domain.
Sourcepub fn format(&self) -> UserNameFormat
pub fn format(&self) -> UserNameFormat
Returns the UserNameFormat for this username
Sourcepub fn domain_name(&self) -> Option<&str>
pub fn domain_name(&self) -> Option<&str>
May return an UPN suffix or NetBIOS domain name depending on the internal format
Sourcepub fn account_name(&self) -> &str
pub fn account_name(&self) -> &str
Returns the account name