mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-21 02:33:14 +00:00
reference id vs external id
This commit is contained in:
@@ -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
|
||||
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
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
Email = entry.Email;
|
||||
Disabled = entry.Disabled;
|
||||
ExternalId = entry.Id;
|
||||
ExternalId = entry.ExternalId;
|
||||
}
|
||||
|
||||
public string ExternalId { get; set; }
|
||||
|
||||
@@ -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
|
||||
{
|
||||
var entry = new UserEntry
|
||||
{
|
||||
Id = user.Id,
|
||||
ReferenceId = user.Id,
|
||||
ExternalId = user.Id,
|
||||
Email = user.Mail ?? user.UserPrincipalName,
|
||||
Disabled = !user.AccountEnabled.GetValueOrDefault(true)
|
||||
};
|
||||
|
||||
@@ -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
|
||||
{
|
||||
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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user