mirror of
https://github.com/bitwarden/directory-connector
synced 2026-01-01 16:13:50 +00:00
email prefix suffix config and set mail priority
This commit is contained in:
@@ -647,6 +647,29 @@ namespace Bit.Console
|
||||
{
|
||||
config.Ldap.GroupNameAttribute = input;
|
||||
}
|
||||
|
||||
Con.Write("Use email prefix/suffix fallback? [{0}]: ", config.Ldap.EmailPrefixSuffix ? "y" : "n");
|
||||
input = Con.ReadLine().ToLower();
|
||||
if(!string.IsNullOrEmpty(input))
|
||||
{
|
||||
config.Ldap.EmailPrefixSuffix = input == "y" || input == "yes";
|
||||
}
|
||||
|
||||
if(config.Ldap.EmailPrefixSuffix)
|
||||
{
|
||||
Con.Write("Email prefix attribute [{0}]: ", config.Ldap.UserEmailPrefixAttribute);
|
||||
input = Con.ReadLine();
|
||||
if(!string.IsNullOrEmpty(input))
|
||||
{
|
||||
config.Ldap.UserEmailPrefixAttribute = input;
|
||||
}
|
||||
Con.Write("Email suffix [{0}]: ", config.Ldap.UserEmailSuffix);
|
||||
input = Con.ReadLine();
|
||||
if(!string.IsNullOrEmpty(input))
|
||||
{
|
||||
config.Ldap.UserEmailSuffix = input;
|
||||
}
|
||||
}
|
||||
}
|
||||
Con.Write("User filter [{0}]: ", config.UserFilter);
|
||||
input = Con.ReadLine();
|
||||
|
||||
@@ -337,7 +337,15 @@ namespace Bit.Core.Services
|
||||
user.Disabled = EntryDisabled(item);
|
||||
|
||||
// Email
|
||||
if(SettingsService.Instance.Sync.Ldap.EmailPrefixSuffix &&
|
||||
if(item.Properties.Contains(SettingsService.Instance.Sync.Ldap.UserEmailAttribute) &&
|
||||
item.Properties[SettingsService.Instance.Sync.Ldap.UserEmailAttribute].Count > 0)
|
||||
{
|
||||
user.Email = item.Properties[SettingsService.Instance.Sync.Ldap.UserEmailAttribute][0]
|
||||
.ToString()
|
||||
.ToLowerInvariant();
|
||||
}
|
||||
|
||||
if(string.IsNullOrWhiteSpace(user.Email) && SettingsService.Instance.Sync.Ldap.EmailPrefixSuffix &&
|
||||
item.Properties.Contains(SettingsService.Instance.Sync.Ldap.UserEmailPrefixAttribute) &&
|
||||
item.Properties[SettingsService.Instance.Sync.Ldap.UserEmailPrefixAttribute].Count > 0 &&
|
||||
!string.IsNullOrWhiteSpace(SettingsService.Instance.Sync.Ldap.UserEmailSuffix))
|
||||
@@ -346,14 +354,8 @@ namespace Bit.Core.Services
|
||||
item.Properties[SettingsService.Instance.Sync.Ldap.UserEmailPrefixAttribute][0].ToString(),
|
||||
SettingsService.Instance.Sync.Ldap.UserEmailSuffix).ToLowerInvariant();
|
||||
}
|
||||
else if(item.Properties.Contains(SettingsService.Instance.Sync.Ldap.UserEmailAttribute) &&
|
||||
item.Properties[SettingsService.Instance.Sync.Ldap.UserEmailAttribute].Count > 0)
|
||||
{
|
||||
user.Email = item.Properties[SettingsService.Instance.Sync.Ldap.UserEmailAttribute][0]
|
||||
.ToString()
|
||||
.ToLowerInvariant();
|
||||
}
|
||||
else if(!user.Disabled && !user.Deleted)
|
||||
|
||||
if(string.IsNullOrWhiteSpace(user.Email) && !user.Disabled && !user.Deleted)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user