September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,59 +1,14 @@
|
|||
import java.io.IOException;
|
||||
|
||||
import org.apache.directory.api.ldap.model.exception.LdapException;
|
||||
import org.apache.directory.ldap.client.api.LdapConnection;
|
||||
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
|
||||
import org.apache.directory.shared.ldap.model.cursor.EntryCursor;
|
||||
import org.apache.directory.shared.ldap.model.entry.Entry;
|
||||
import org.apache.directory.shared.ldap.model.exception.LdapException;
|
||||
import org.apache.directory.shared.ldap.model.message.SearchScope;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RDirectoryLDAP {
|
||||
public class LdapConnectionDemo {
|
||||
|
||||
static final Logger log_;
|
||||
private static final String ldapHostName;
|
||||
private static final int ldapPort;
|
||||
private static LdapConnection connection;
|
||||
|
||||
static {
|
||||
log_ = LoggerFactory.getLogger(RDirectoryLDAP.class);
|
||||
connection = null;
|
||||
ldapHostName = "localhost";
|
||||
ldapPort = 10389;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
if (log_.isInfoEnabled()) { log_.info("LDAP Connection to " + ldapHostName + " on port " + ldapPort); }
|
||||
connection = new LdapNetworkConnection(ldapHostName, ldapPort);
|
||||
|
||||
try {
|
||||
if (log_.isTraceEnabled()) { log_.trace("LDAP bind"); }
|
||||
connection.bind();
|
||||
|
||||
if (log_.isTraceEnabled()) { log_.trace("LDAP unbind"); }
|
||||
connection.unBind();
|
||||
}
|
||||
catch (LdapException lex) {
|
||||
log_.error("LDAP Error", lex);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
log_.error("I/O Error", ex);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (log_.isTraceEnabled()) { log_.trace("LDAP close connection"); }
|
||||
try {
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
public static void main(String[] args) throws LdapException, IOException {
|
||||
try (LdapConnection connection = new LdapNetworkConnection("localhost", 10389)) {
|
||||
connection.bind();
|
||||
connection.unBind();
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
log_.error("I/O Error on connection.close()", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue