我需要使用多个LDAP提供程序.如何检查LDAP服务器的可用性? [英] I need to use multiple LDAP provider. How can I check LDAP server availability?

查看:324
本文介绍了我需要使用多个LDAP提供程序.如何检查LDAP服务器的可用性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有多个LDAP/域服务器.(例如LDAP://server1.com:389/DC=server1,DC=COMLDAP://server2.com:389/DC=server2,DC=COM)我需要通过检查可用性来使用其中之一.

We have multiple LDAP/domain servers.(ex. LDAP://server1.com:389/DC=server1,DC=COM, LDAP://server2.com:389/DC=server2,DC=COM) I need to use one of them by checking availabilty.

try {
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "LDAP://server1.com:389/DC=server1,DC=COM");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, username);
    env.put(Context.SECURITY_CREDENTIALS, password);

    DirContext ctx = new InitialDirContext(env);
} catch(NamingException ex) {
}

推荐答案

您可以执行简单的匿名搜索以查看LDAP服务器是否已启动并正在运行.如果出现连接被拒绝"异常,则服务器将关闭,您可以切换到列表中的下一个,再次执行相同的操作.

You can perform a simple anonymous search to see if the LDAP server is up and running. If you get a Connection refused exception, then the server would be down and you can switch to the next one in your list, perform the same operation again.

通常,将在一系列域控制器的前面放置负载均衡器,将请求路由到负载均衡器,该负载均衡器将标识正确的DC并将其代理给它. LB负责定期检查其列表中的DC的可用性,如果DC断开则将其删除,在DC接通时再次检查它们,等等.您可能需要向您的IT部门咨询有关您环境中是否存在这样的LB的信息.

Usually there would be load balancers sitting in front of a string of domain controllers, the requests are routed to the load balancer which would identify the right DC and proxies the request to it. The LB takes care of periodically checking the availability of DCs in its list, remove them if they went down, check them back again when they are on etc.,. You may want to check with your IT department about existence of such an LB in your environment.

这篇关于我需要使用多个LDAP提供程序.如何检查LDAP服务器的可用性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆