mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-11 13:53:22 +00:00
group and user filters
This commit is contained in:
@@ -229,6 +229,16 @@ namespace Bit.Console
|
|||||||
{
|
{
|
||||||
config.Password = new EncryptedData(parameters["p"]);
|
config.Password = new EncryptedData(parameters["p"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(parameters.ContainsKey("gf"))
|
||||||
|
{
|
||||||
|
config.GroupFilter = parameters["gf"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parameters.ContainsKey("uf"))
|
||||||
|
{
|
||||||
|
config.UserFilter = parameters["uf"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -251,6 +261,11 @@ namespace Bit.Console
|
|||||||
config.Password = new EncryptedData(passwordInput);
|
config.Password = new EncryptedData(passwordInput);
|
||||||
passwordInput = null;
|
passwordInput = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Con.Write("Group filter: ");
|
||||||
|
config.GroupFilter = Con.ReadLine().Trim();
|
||||||
|
Con.Write("User filter: ");
|
||||||
|
config.UserFilter = Con.ReadLine().Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
Con.WriteLine();
|
Con.WriteLine();
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace Bit.Core.Models
|
|||||||
public EncryptedData Password { get; set; }
|
public EncryptedData Password { get; set; }
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string ServerPath => $"LDAP://{Address}:{Port}/{Path}";
|
public string ServerPath => $"LDAP://{Address}:{Port}/{Path}";
|
||||||
|
public string GroupFilter { get; set; }
|
||||||
|
public string UserFilter { get; set; }
|
||||||
|
|
||||||
public DirectoryEntry GetDirectoryEntry()
|
public DirectoryEntry GetDirectoryEntry()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ namespace Bit.Core.Utilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entry = Services.SettingsService.Instance.Server.GetDirectoryEntry();
|
var entry = Services.SettingsService.Instance.Server.GetDirectoryEntry();
|
||||||
var searcher = new DirectorySearcher(entry);
|
var filter = string.IsNullOrWhiteSpace(Services.SettingsService.Instance.Server.GroupFilter) ? null :
|
||||||
|
Services.SettingsService.Instance.Server.GroupFilter;
|
||||||
|
var searcher = new DirectorySearcher(entry, filter);
|
||||||
var result = searcher.FindAll();
|
var result = searcher.FindAll();
|
||||||
|
|
||||||
PrintSearchResults(result);
|
PrintSearchResults(result);
|
||||||
@@ -43,13 +45,21 @@ namespace Bit.Core.Utilities
|
|||||||
throw new ApplicationException("Not authenticated.");
|
throw new ApplicationException("Not authenticated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var entry = Services.SettingsService.Instance.Server.GetDirectoryEntry();
|
||||||
|
var filter = string.IsNullOrWhiteSpace(Services.SettingsService.Instance.Server.UserFilter) ? null :
|
||||||
|
Services.SettingsService.Instance.Server.UserFilter;
|
||||||
|
var searcher = new DirectorySearcher(entry, filter);
|
||||||
|
var result = searcher.FindAll();
|
||||||
|
|
||||||
|
PrintSearchResults(result);
|
||||||
|
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task SyncAllAsync()
|
public static async Task SyncAllAsync()
|
||||||
{
|
{
|
||||||
await SyncGroupsAsync();
|
await SyncGroupsAsync();
|
||||||
await SyncUsersAsync();
|
//await SyncUsersAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PrintSearchResults(SearchResultCollection result)
|
private static void PrintSearchResults(SearchResultCollection result)
|
||||||
|
|||||||
Reference in New Issue
Block a user