fix
This commit is contained in:
parent
a60b74c564
commit
a858ba68d3
@ -23,15 +23,14 @@ public abstract class LdapHelper : IDisposable
|
||||
public abstract bool IsConnected { get; }
|
||||
|
||||
protected readonly ILog Log;
|
||||
|
||||
private readonly InstanceCrypto _instanceCrypto;
|
||||
protected readonly InstanceCrypto InstanceCrypto;
|
||||
|
||||
protected LdapHelper(
|
||||
IOptionsMonitor<ILog> option,
|
||||
InstanceCrypto instanceCrypto)
|
||||
{
|
||||
Log = option.Get("ASC");
|
||||
_instanceCrypto = instanceCrypto;
|
||||
InstanceCrypto = instanceCrypto;
|
||||
}
|
||||
|
||||
public void Init(LdapSettings settings)
|
||||
@ -108,7 +107,7 @@ public abstract class LdapHelper : IDisposable
|
||||
string password;
|
||||
try
|
||||
{
|
||||
password = _instanceCrypto.Decrypt(passwordBytes);
|
||||
password = InstanceCrypto.Decrypt(passwordBytes);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -123,7 +122,7 @@ public abstract class LdapHelper : IDisposable
|
||||
|
||||
try
|
||||
{
|
||||
passwordBytes = _instanceCrypto.Encrypt(new UnicodeEncoding().GetBytes(password));
|
||||
passwordBytes = InstanceCrypto.Encrypt(new UnicodeEncoding().GetBytes(password));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ public class LdapNotifyHelper
|
||||
private readonly DistributedTaskQueue _ldapTasks;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
LdapNotifyHelper(
|
||||
public LdapNotifyHelper(
|
||||
IServiceProvider serviceProvider,
|
||||
DistributedTaskQueueOptionsManager distributedTaskQueueOptionsManager)
|
||||
{
|
||||
|
@ -60,21 +60,16 @@ public abstract class LdapOperation
|
||||
|
||||
public static LdapLocalization Resource { get; private set; }
|
||||
|
||||
protected IOptionsMonitor<ILog> Options { get; private set; }
|
||||
|
||||
protected TenantManager TenantManager { get; private set; }
|
||||
|
||||
protected SecurityContext SecurityContext { get; private set; }
|
||||
|
||||
protected NovellLdapHelper NovellLdapHelper { get; }
|
||||
|
||||
private SecurityContext _securityContext;
|
||||
private NovellLdapHelper _novellLdapHelper;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
protected LdapOperation(IServiceProvider serviceProvider, IOptionsMonitor<ILog> options)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
Options = options;
|
||||
Logger = Options.Get("ASC");
|
||||
Logger = options.Get("ASC");
|
||||
}
|
||||
|
||||
public void Init(
|
||||
@ -107,9 +102,10 @@ public abstract class LdapOperation
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
TenantManager = scope.ServiceProvider.GetService<TenantManager>();
|
||||
SecurityContext = scope.ServiceProvider.GetService<SecurityContext>();
|
||||
_securityContext = scope.ServiceProvider.GetService<SecurityContext>();
|
||||
LDAPUserManager = scope.ServiceProvider.GetService<LdapUserManager>();
|
||||
LDAPUserManager.Init(Resource);
|
||||
_novellLdapHelper = scope.ServiceProvider.GetService<NovellLdapHelper>();
|
||||
Importer = scope.ServiceProvider.GetService<NovellLdapUserImporter>();
|
||||
|
||||
try
|
||||
@ -118,7 +114,7 @@ public abstract class LdapOperation
|
||||
|
||||
TenantManager.SetCurrentTenant(CurrentTenant);
|
||||
|
||||
SecurityContext.AuthenticateMe(Core.Configuration.Constants.CoreSystem);
|
||||
_securityContext.AuthenticateMe(Core.Configuration.Constants.CoreSystem);
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(_culture);
|
||||
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(_culture);
|
||||
@ -221,7 +217,7 @@ public abstract class LdapOperation
|
||||
{
|
||||
TaskInfo.SetProperty(FINISHED, true);
|
||||
PublishTaskInfo();
|
||||
SecurityContext.Logout();
|
||||
_securityContext.Logout();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -397,7 +393,7 @@ public abstract class LdapOperation
|
||||
{
|
||||
if (!string.IsNullOrEmpty(settings.Password))
|
||||
{
|
||||
settings.PasswordBytes = NovellLdapHelper.GetPasswordBytes(settings.Password);
|
||||
settings.PasswordBytes = _novellLdapHelper.GetPasswordBytes(settings.Password);
|
||||
|
||||
if (settings.PasswordBytes == null)
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ global using ASC.Web.Studio.Utility;
|
||||
|
||||
global using Microsoft.Extensions.Configuration;
|
||||
global using Microsoft.Extensions.DependencyInjection;
|
||||
global using Microsoft.Extensions.Hosting;
|
||||
global using Microsoft.Extensions.Options;
|
||||
|
||||
global using Novell.Directory.Ldap;
|
||||
|
@ -19,15 +19,14 @@ namespace ASC.ActiveDirectory.Novell;
|
||||
[Scope]
|
||||
public class NovellLdapHelper : LdapHelper
|
||||
{
|
||||
public NovellLdapSearcher LDAPSearcher { get; private set; }
|
||||
|
||||
private readonly NovellLdapSearcher _lDAPSearcher;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public NovellLdapHelper(IServiceProvider serviceProvider, IOptionsMonitor<ILog> option, InstanceCrypto instanceCrypto, IConfiguration configuration, NovellLdapSearcher novellLdapSearcher) :
|
||||
base(option, instanceCrypto)
|
||||
{
|
||||
LDAPSearcher = novellLdapSearcher;
|
||||
_lDAPSearcher = novellLdapSearcher;
|
||||
|
||||
_configuration = configuration;
|
||||
_serviceProvider = serviceProvider;
|
||||
@ -39,7 +38,7 @@ public class NovellLdapHelper : LdapHelper
|
||||
? GetPassword(settings.PasswordBytes)
|
||||
: settings.Password;
|
||||
|
||||
LDAPSearcher.Init(settings.Login, password, settings.Server, settings.PortNumber,
|
||||
_lDAPSearcher.Init(settings.Login, password, settings.Server, settings.PortNumber,
|
||||
settings.StartTls, settings.Ssl, settings.AcceptCertificate, settings.AcceptCertificateHash);
|
||||
|
||||
base.Init(settings);
|
||||
@ -47,20 +46,20 @@ public class NovellLdapHelper : LdapHelper
|
||||
|
||||
public override bool IsConnected
|
||||
{
|
||||
get { return LDAPSearcher.IsConnected; }
|
||||
get { return _lDAPSearcher.IsConnected; }
|
||||
}
|
||||
|
||||
public override void Connect()
|
||||
{
|
||||
LDAPSearcher.Connect();
|
||||
_lDAPSearcher.Connect();
|
||||
|
||||
Settings.AcceptCertificate = LDAPSearcher.AcceptCertificate;
|
||||
Settings.AcceptCertificateHash = LDAPSearcher.AcceptCertificateHash;
|
||||
Settings.AcceptCertificate = _lDAPSearcher.AcceptCertificate;
|
||||
Settings.AcceptCertificateHash = _lDAPSearcher.AcceptCertificateHash;
|
||||
}
|
||||
|
||||
public override Dictionary<string, string[]> GetCapabilities()
|
||||
{
|
||||
return LDAPSearcher.GetCapabilities();
|
||||
return _lDAPSearcher.GetCapabilities();
|
||||
}
|
||||
|
||||
public override string SearchDomain()
|
||||
@ -122,7 +121,7 @@ public class NovellLdapHelper : LdapHelper
|
||||
try
|
||||
{
|
||||
var searchResult =
|
||||
LDAPSearcher.Search(Settings.UserDN, NovellLdapSearcher.LdapScope.Sub, Settings.UserFilter, limit: 1)
|
||||
_lDAPSearcher.Search(Settings.UserDN, NovellLdapSearcher.LdapScope.Sub, Settings.UserFilter, limit: 1)
|
||||
.FirstOrDefault();
|
||||
|
||||
return searchResult != null ? LdapObjectExtension.GetDomainFromDn(searchResult) : null;
|
||||
@ -147,7 +146,7 @@ public class NovellLdapHelper : LdapHelper
|
||||
{
|
||||
string[] attributes = { LdapConstants.ADSchemaAttributes.OBJECT_CLASS };
|
||||
|
||||
var searchResult = LDAPSearcher.Search(userDn, NovellLdapSearcher.LdapScope.Base,
|
||||
var searchResult = _lDAPSearcher.Search(userDn, NovellLdapSearcher.LdapScope.Base,
|
||||
LdapConstants.OBJECT_FILTER, attributes, 1);
|
||||
|
||||
if (searchResult.Any())
|
||||
@ -161,7 +160,7 @@ public class NovellLdapHelper : LdapHelper
|
||||
{
|
||||
string[] attributes = { LdapConstants.ADSchemaAttributes.OBJECT_CLASS };
|
||||
|
||||
var searchResult = LDAPSearcher.Search(groupDn, NovellLdapSearcher.LdapScope.Base,
|
||||
var searchResult = _lDAPSearcher.Search(groupDn, NovellLdapSearcher.LdapScope.Base,
|
||||
LdapConstants.OBJECT_FILTER, attributes, 1);
|
||||
|
||||
if (searchResult.Any())
|
||||
@ -193,7 +192,7 @@ public class NovellLdapHelper : LdapHelper
|
||||
? Settings.UserFilter
|
||||
: string.Format("(&{0}{1})", Settings.UserFilter, filter);
|
||||
|
||||
list = LDAPSearcher.Search(Settings.UserDN, NovellLdapSearcher.LdapScope.Sub, searchfilter, limit: limit);
|
||||
list = _lDAPSearcher.Search(Settings.UserDN, NovellLdapSearcher.LdapScope.Sub, searchfilter, limit: limit);
|
||||
|
||||
return list;
|
||||
}
|
||||
@ -230,7 +229,7 @@ public class NovellLdapHelper : LdapHelper
|
||||
|
||||
var searchfilter = string.Format("(&{0}{1})", Settings.UserFilter, criteria);
|
||||
|
||||
var list = LDAPSearcher.Search(Settings.UserDN, NovellLdapSearcher.LdapScope.Sub, searchfilter, limit: 1);
|
||||
var list = _lDAPSearcher.Search(Settings.UserDN, NovellLdapSearcher.LdapScope.Sub, searchfilter, limit: 1);
|
||||
|
||||
return list.FirstOrDefault();
|
||||
}
|
||||
@ -259,7 +258,7 @@ public class NovellLdapHelper : LdapHelper
|
||||
: string.Format("(&{0}{1})", Settings.GroupFilter, criteria);
|
||||
|
||||
|
||||
list = LDAPSearcher.Search(Settings.GroupDN, NovellLdapSearcher.LdapScope.Sub, searchfilter);
|
||||
list = _lDAPSearcher.Search(Settings.GroupDN, NovellLdapSearcher.LdapScope.Sub, searchfilter);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -271,6 +270,6 @@ public class NovellLdapHelper : LdapHelper
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
LDAPSearcher.Dispose();
|
||||
_lDAPSearcher.Dispose();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user