mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-19 17:53:20 +00:00
tweaks for ldap
This commit is contained in:
@@ -342,6 +342,13 @@ namespace Bit.Console
|
||||
config.Ldap.Path = parameters["path"];
|
||||
}
|
||||
|
||||
if(parameters.ContainsKey("cu"))
|
||||
{
|
||||
config.Ldap.Username = null;
|
||||
config.Ldap.Password = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(parameters.ContainsKey("u"))
|
||||
{
|
||||
config.Ldap.Username = parameters["u"];
|
||||
@@ -353,6 +360,7 @@ namespace Bit.Console
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string input;
|
||||
@@ -419,7 +427,7 @@ namespace Bit.Console
|
||||
}
|
||||
else
|
||||
{
|
||||
config.Ldap = new LdapConfiguration();
|
||||
config.Ldap = config.Ldap ?? new LdapConfiguration();
|
||||
|
||||
Con.Write("Address [{0}]: ", config.Ldap.Address);
|
||||
input = Con.ReadLine();
|
||||
@@ -439,6 +447,23 @@ namespace Bit.Console
|
||||
{
|
||||
config.Ldap.Path = input.Trim();
|
||||
}
|
||||
|
||||
var currentUser = string.IsNullOrWhiteSpace(config.Ldap.Username) &&
|
||||
config.Ldap.Password == null;
|
||||
Con.Write("Authenticate as current user? [{0}]: ", currentUser ? "y" : "n");
|
||||
input = Con.ReadLine().ToLower();
|
||||
if(!string.IsNullOrEmpty(input))
|
||||
{
|
||||
currentUser = input == "y" || input == "yes";
|
||||
}
|
||||
|
||||
if(currentUser)
|
||||
{
|
||||
config.Ldap.Username = null;
|
||||
config.Ldap.Password = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Con.Write("Username [{0}]: ", config.Ldap.Username);
|
||||
input = Con.ReadLine();
|
||||
if(!string.IsNullOrEmpty(input))
|
||||
@@ -453,6 +478,7 @@ namespace Bit.Console
|
||||
input = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input = null;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,14 @@ namespace Bit.Core.Models
|
||||
|
||||
public DirectoryEntry GetDirectoryEntry()
|
||||
{
|
||||
var entry = new DirectoryEntry(ServerPath, Username, Password.DecryptToString(), AuthenticationTypes.None);
|
||||
return entry;
|
||||
if(Password == null && string.IsNullOrWhiteSpace(Username))
|
||||
{
|
||||
return new DirectoryEntry(ServerPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new DirectoryEntry(ServerPath, Username, Password.DecryptToString(), AuthenticationTypes.None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace Bit.Core.Services
|
||||
|
||||
if(item.Properties.Contains("objectGUID") && item.Properties["objectGUID"].Count > 0)
|
||||
{
|
||||
externalId = item.Properties["objectGUID"][0].ToString();
|
||||
externalId = item.Properties["objectGUID"][0].FromGuidToString();
|
||||
}
|
||||
|
||||
dict.Add(referenceId, externalId);
|
||||
@@ -172,7 +172,7 @@ namespace Bit.Core.Services
|
||||
// External Id
|
||||
if(item.Properties.Contains("objectGUID") && item.Properties["objectGUID"].Count > 0)
|
||||
{
|
||||
group.ExternalId = item.Properties["objectGUID"][0].ToString();
|
||||
group.ExternalId = item.Properties["objectGUID"][0].FromGuidToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -309,7 +309,7 @@ namespace Bit.Core.Services
|
||||
// External Id
|
||||
if(item.Properties.Contains("objectGUID") && item.Properties["objectGUID"].Count > 0)
|
||||
{
|
||||
user.ExternalId = item.Properties["objectGUID"][0].ToString();
|
||||
user.ExternalId = item.Properties["objectGUID"][0].FromGuidToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -52,5 +52,18 @@ namespace Bit.Core.Utilities
|
||||
|
||||
return queryParameters;
|
||||
}
|
||||
|
||||
public static string FromGuidToString(this object property)
|
||||
{
|
||||
var propBytes = property as byte[];
|
||||
if(propBytes != null)
|
||||
{
|
||||
return new Guid(propBytes).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return property.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user