2016-02-28 49 views

回答

0

UnboundID LDAP中有很多選項。如果需要,可以使用連接池,這將減少連接建立時LDAP服務器的額外負載。 使連接池

try { 
    connection = new LDAPConnection(address, port); 
    BindResult bindResult = connection.bind(DN, password); 
    connectionPool = new LDAPConnectionPool(connection, max_numbof_connection);  
    } catch (LDAPException e) { 
     String es = e.getExceptionMessage(); 
     System.out.println(es); 
    } 

您可以通過一個單一的連接也實現這一目標。 首先,您需要使用地址和端口進行未經身份驗證的連接,然後使用DN和密碼綁定該連接。在綁定請求中,您可能會發現給定的DN是否是授權的。

例如從連接認證用戶無需連接池

LDAPConnection connection = new LDAPConnection(); 
connection.connect("server.example.com", 389); 
connection.bind("uid=john.doe,ou=People,dc=example,dc=com", "password'); 
+0

謝謝你的解釋。我正在找到一個很好的來源來實現這一點。我會按照上面的答案回覆你。你能爲我找到一個很好的來源嗎? – ShaAk