Exemple #1
0
        public static void AddLdap(this IServiceCollection services, IConfiguration configuration)
        {
            var ldapConfig = new LDAPConfiguration();

            configuration.Bind("LDAP", ldapConfig);
            services.AddSingleton(ldapConfig);

            services.TryAddScoped <ILdapService, LdapService>();
        }
Exemple #2
0
        /// <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();
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 public LdapService(ILogger <LdapService> logger, LDAPConfiguration config)
 {
     _logger = logger;
     _config = config;
 }