public static void AddLdap(this IServiceCollection services, IConfiguration configuration) { var ldapConfig = new LDAPConfiguration(); configuration.Bind("LDAP", ldapConfig); services.AddSingleton(ldapConfig); services.TryAddScoped <ILdapService, LdapService>(); }
/// <summary>重新加载</summary> private void Reload() { configuration = LDAPConfigurationView.Instance.Configuration; this.integratedMode = LDAPConfigurationView.Instance.IntegratedMode; directoryEntry = new DirectoryEntry(LDAPConfigurationView.Instance.LDAPPath, LDAPConfigurationView.Instance.LoginName, LDAPConfigurationView.Instance.Password); directorySearcher = new DirectorySearcher(); Initialize(); }
private static ILdapConnection getLdapConnection(LDAPConfiguration configuration) { if (!(_conn is LdapConnection ldapConn)) { // Creating an LdapConnection instance ldapConn = new LdapConnection() { SecureSocketLayer = true }; ldapConn.Connect(configuration.Server, LdapConnection.DefaultSslPort); //Bind function with null user dn and password value will perform anonymous bind to LDAP server ldapConn.Bind(configuration.UName, configuration.Password); _conn = ldapConn; } return(ldapConn); }
public LdapService(ILogger <LdapService> logger, LDAPConfiguration config) { _logger = logger; _config = config; }