diff --git a/src/Core/Models/SyncConfiguration.cs b/src/Core/Models/SyncConfiguration.cs index 97e90655..9096c280 100644 --- a/src/Core/Models/SyncConfiguration.cs +++ b/src/Core/Models/SyncConfiguration.cs @@ -18,7 +18,6 @@ namespace Bit.Core.Models switch(type) { case DirectoryType.ActiveDirectory: - MemberAttribute = "memberOf"; CreationDateAttribute = "whenCreated"; RevisionDateAttribute = "whenChanged"; UserEmailPrefixAttribute = "sAMAccountName"; @@ -33,7 +32,7 @@ namespace Bit.Core.Models UserEmailSuffix = null; break; case DirectoryType.Other: - IntervalMinutes = 30; + IntervalMinutes = 60; break; default: break; diff --git a/src/Core/Services/LdapDirectoryService.cs b/src/Core/Services/LdapDirectoryService.cs index 486fcf60..07178077 100644 --- a/src/Core/Services/LdapDirectoryService.cs +++ b/src/Core/Services/LdapDirectoryService.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.DirectoryServices; using System.Linq; +using System.Net; using System.Threading.Tasks; namespace Bit.Core.Services @@ -104,7 +105,7 @@ namespace Bit.Core.Services var initialSearchGroupIds = new List(); foreach(SearchResult item in result) { - initialSearchGroupIds.Add(new Uri(item.Path).Segments?.LastOrDefault()); + initialSearchGroupIds.Add(DNFromPath(item.Path)); } if(searchSinceRevision && !initialSearchGroupIds.Any()) @@ -144,7 +145,7 @@ namespace Bit.Core.Services var dict = new Dictionary(); foreach(SearchResult item in result) { - var referenceId = new Uri(item.Path).Segments?.LastOrDefault(); + var referenceId = DNFromPath(item.Path); var externalId = referenceId; if(item.Properties.Contains("objectGUID") && item.Properties["objectGUID"].Count > 0) @@ -161,7 +162,7 @@ namespace Bit.Core.Services { var group = new GroupEntry { - ReferenceId = new Uri(item.Path).Segments?.LastOrDefault() + ReferenceId = DNFromPath(item.Path) }; if(group.ReferenceId == null) @@ -297,7 +298,7 @@ namespace Bit.Core.Services { var user = new UserEntry { - ReferenceId = new Uri(item.Path).Segments?.LastOrDefault(), + ReferenceId = DNFromPath(item.Path), Deleted = deleted }; @@ -362,5 +363,16 @@ namespace Bit.Core.Services return (control & UserAccountControl.AccountDisabled) == UserAccountControl.AccountDisabled; } + + private static string DNFromPath(string path) + { + var dn = new Uri(path).Segments?.LastOrDefault(); + if(dn == null) + { + return null; + } + + return WebUtility.UrlDecode(dn); + } } } diff --git a/src/Service/Service.cs b/src/Service/Service.cs index 6cc0804d..2d42244b 100644 --- a/src/Service/Service.cs +++ b/src/Service/Service.cs @@ -76,9 +76,9 @@ namespace Service } var intervalMinutes = SettingsService.Instance.Sync.IntervalMinutes; - if(SettingsService.Instance.Server.Type == Bit.Core.Enums.DirectoryType.Other && intervalMinutes < 30) + if(SettingsService.Instance.Server.Type == Bit.Core.Enums.DirectoryType.Other && intervalMinutes < 60) { - intervalMinutes = 30; + intervalMinutes = 60; } else if(intervalMinutes < 1) {