Browse Source

reference id vs external id

pull/1/head
Kyle Spearrin 9 years ago
parent
commit
e6af13d935
  1. 4
      src/Console/Program.cs
  2. 3
      src/Core/Models/Entry.cs
  3. 4
      src/Core/Models/ImportRequest.cs
  4. 6
      src/Core/Services/AzureDirectoryService.cs
  5. 28
      src/Core/Services/LdapDirectoryService.cs
  6. 12
      src/Core/Utilities/Sync.cs

4
src/Console/Program.cs

@ -673,7 +673,7 @@ namespace Bit.Console @@ -673,7 +673,7 @@ namespace Bit.Console
Con.WriteLine("Groups:");
foreach(var group in result.Groups)
{
Con.WriteLine(" {0} - {1}", group.Name, group.Id);
Con.WriteLine(" {0} - {1}", group.Name, group.ExternalId);
foreach(var user in group.Users)
{
Con.WriteLine(" {0}", user);
@ -684,7 +684,7 @@ namespace Bit.Console @@ -684,7 +684,7 @@ namespace Bit.Console
Con.WriteLine("Users:");
foreach(var user in result.Users)
{
Con.WriteLine(" {0}{1}", user.Email ?? user.Id, user.Disabled ? " (disabled)" : null);
Con.WriteLine(" {0}{1}", user.Email ?? user.ExternalId, user.Disabled ? " (disabled)" : null);
}
}
else

3
src/Core/Models/Entry.cs

@ -8,7 +8,8 @@ namespace Bit.Core.Models @@ -8,7 +8,8 @@ namespace Bit.Core.Models
{
public abstract class Entry
{
public string Id { get; set; }
public string ReferenceId { get; set; }
public string ExternalId { get; set; }
public DateTime? CreationDate { get; set; }
public DateTime? RevisionDate { get; set; }
}

4
src/Core/Models/ImportRequest.cs

@ -19,7 +19,7 @@ namespace Bit.Core.Models @@ -19,7 +19,7 @@ namespace Bit.Core.Models
public Group(GroupEntry entry)
{
Name = entry.Name;
ExternalId = entry.Id;
ExternalId = entry.ExternalId;
Users = entry.Users;
}
@ -34,7 +34,7 @@ namespace Bit.Core.Models @@ -34,7 +34,7 @@ namespace Bit.Core.Models
{
Email = entry.Email;
Disabled = entry.Disabled;
ExternalId = entry.Id;
ExternalId = entry.ExternalId;
}
public string ExternalId { get; set; }

6
src/Core/Services/AzureDirectoryService.cs

@ -117,7 +117,8 @@ namespace Bit.Core.Services @@ -117,7 +117,8 @@ namespace Bit.Core.Services
{
var entry = new GroupEntry
{
Id = group.Id,
ReferenceId = group.Id,
ExternalId = group.Id,
Name = group.DisplayName
};
@ -204,7 +205,8 @@ namespace Bit.Core.Services @@ -204,7 +205,8 @@ namespace Bit.Core.Services
{
var entry = new UserEntry
{
Id = user.Id,
ReferenceId = user.Id,
ExternalId = user.Id,
Email = user.Mail ?? user.UserPrincipalName,
Disabled = !user.AccountEnabled.GetValueOrDefault(true)
};

28
src/Core/Services/LdapDirectoryService.cs

@ -103,14 +103,24 @@ namespace Bit.Core.Services @@ -103,14 +103,24 @@ namespace Bit.Core.Services
{
var group = new GroupEntry
{
Id = new Uri(item.Path).Segments?.LastOrDefault()
ReferenceId = new Uri(item.Path).Segments?.LastOrDefault()
};
if(group.Id == null)
if(group.ReferenceId == null)
{
continue;
}
// External Id
if(item.Properties.Contains("objectGUID") && item.Properties["objectGUID"].Count > 0)
{
group.ExternalId = item.Properties["objectGUID"][0].ToString();
}
else
{
group.ExternalId = group.ReferenceId;
}
// Name
if(item.Properties.Contains(SettingsService.Instance.Sync.GroupNameAttribute) &&
item.Properties[SettingsService.Instance.Sync.GroupNameAttribute].Count > 0)
@ -193,14 +203,24 @@ namespace Bit.Core.Services @@ -193,14 +203,24 @@ namespace Bit.Core.Services
{
var user = new UserEntry
{
Id = new Uri(item.Path).Segments?.LastOrDefault()
ReferenceId = new Uri(item.Path).Segments?.LastOrDefault()
};
if(user.Id == null)
if(user.ReferenceId == null)
{
continue;
}
// External Id
if(item.Properties.Contains("objectGUID") && item.Properties["objectGUID"].Count > 0)
{
user.ExternalId = item.Properties["objectGUID"][0].ToString();
}
else
{
user.ExternalId = user.ReferenceId;
}
user.Disabled = EntryDisabled(item);
// Email

12
src/Core/Utilities/Sync.cs

@ -86,14 +86,14 @@ namespace Bit.Core.Utilities @@ -86,14 +86,14 @@ namespace Bit.Core.Utilities
{
foreach(var group in currentGroups)
{
var groupsInThisGroup = allGroups.Where(g => group.Members.Contains(g.Id)).ToList();
var usersInThisGroup = allUsers.Where(u => group.Members.Contains(u.Id)).ToList();
var groupsInThisGroup = allGroups.Where(g => group.Members.Contains(g.ReferenceId)).ToList();
var usersInThisGroup = allUsers.Where(u => group.Members.Contains(u.ReferenceId)).ToList();
foreach(var user in usersInThisGroup)
{
if(!group.Users.Contains(user.Id))
if(!group.Users.Contains(user.ExternalId))
{
group.Users.Add(user.Id);
group.Users.Add(user.ExternalId);
}
}
@ -101,9 +101,9 @@ namespace Bit.Core.Utilities @@ -101,9 +101,9 @@ namespace Bit.Core.Utilities
{
foreach(var user in currentGroupsUsers)
{
if(!group.Users.Contains(user.Id))
if(!group.Users.Contains(user.ExternalId))
{
group.Users.Add(user.Id);
group.Users.Add(user.ExternalId);
}
}

Loading…
Cancel
Save