1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-15 15:53:41 +00:00

adjustments for ldap

This commit is contained in:
Kyle Spearrin
2017-05-17 17:16:03 -04:00
parent 4b6b2884cb
commit 9c3f5a8e6b
3 changed files with 19 additions and 8 deletions

View File

@@ -18,7 +18,6 @@ namespace Bit.Core.Models
switch(type) switch(type)
{ {
case DirectoryType.ActiveDirectory: case DirectoryType.ActiveDirectory:
MemberAttribute = "memberOf";
CreationDateAttribute = "whenCreated"; CreationDateAttribute = "whenCreated";
RevisionDateAttribute = "whenChanged"; RevisionDateAttribute = "whenChanged";
UserEmailPrefixAttribute = "sAMAccountName"; UserEmailPrefixAttribute = "sAMAccountName";
@@ -33,7 +32,7 @@ namespace Bit.Core.Models
UserEmailSuffix = null; UserEmailSuffix = null;
break; break;
case DirectoryType.Other: case DirectoryType.Other:
IntervalMinutes = 30; IntervalMinutes = 60;
break; break;
default: default:
break; break;

View File

@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.DirectoryServices; using System.DirectoryServices;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Bit.Core.Services namespace Bit.Core.Services
@@ -104,7 +105,7 @@ namespace Bit.Core.Services
var initialSearchGroupIds = new List<string>(); var initialSearchGroupIds = new List<string>();
foreach(SearchResult item in result) foreach(SearchResult item in result)
{ {
initialSearchGroupIds.Add(new Uri(item.Path).Segments?.LastOrDefault()); initialSearchGroupIds.Add(DNFromPath(item.Path));
} }
if(searchSinceRevision && !initialSearchGroupIds.Any()) if(searchSinceRevision && !initialSearchGroupIds.Any())
@@ -144,7 +145,7 @@ namespace Bit.Core.Services
var dict = new Dictionary<string, string>(); var dict = new Dictionary<string, string>();
foreach(SearchResult item in result) foreach(SearchResult item in result)
{ {
var referenceId = new Uri(item.Path).Segments?.LastOrDefault(); var referenceId = DNFromPath(item.Path);
var externalId = referenceId; var externalId = referenceId;
if(item.Properties.Contains("objectGUID") && item.Properties["objectGUID"].Count > 0) if(item.Properties.Contains("objectGUID") && item.Properties["objectGUID"].Count > 0)
@@ -161,7 +162,7 @@ namespace Bit.Core.Services
{ {
var group = new GroupEntry var group = new GroupEntry
{ {
ReferenceId = new Uri(item.Path).Segments?.LastOrDefault() ReferenceId = DNFromPath(item.Path)
}; };
if(group.ReferenceId == null) if(group.ReferenceId == null)
@@ -297,7 +298,7 @@ namespace Bit.Core.Services
{ {
var user = new UserEntry var user = new UserEntry
{ {
ReferenceId = new Uri(item.Path).Segments?.LastOrDefault(), ReferenceId = DNFromPath(item.Path),
Deleted = deleted Deleted = deleted
}; };
@@ -362,5 +363,16 @@ namespace Bit.Core.Services
return (control & UserAccountControl.AccountDisabled) == UserAccountControl.AccountDisabled; 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);
}
} }
} }

View File

@@ -76,9 +76,9 @@ namespace Service
} }
var intervalMinutes = SettingsService.Instance.Sync.IntervalMinutes; 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) else if(intervalMinutes < 1)
{ {