本文整理了Java中com.unboundid.ldap.sdk.LDAPConnection.close()
方法的一些代码示例,展示了LDAPConnection.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LDAPConnection.close()
方法的具体详情如下:
包路径:com.unboundid.ldap.sdk.LDAPConnection
类名称:LDAPConnection
方法名:close
[英]Unbinds from the server and closes the connection.
If this method is invoked while any operations are in progress on this connection, then the directory server may or may not abort processing for those operations, depending on the type of operation and how far along the server has already gotten while processing that operation. It is recommended that all active operations be abandoned, canceled, or allowed to complete before attempting to close an active connection.
[中]从服务器解除绑定并关闭连接。
如果在此连接上正在进行任何操作时调用此方法,则目录服务器可能会也可能不会中止这些操作的处理,具体取决于操作类型以及服务器在处理该操作时已经走了多远。建议在尝试关闭活动连接之前放弃、取消或允许完成所有活动操作。
代码示例来源:origin: tmobile/pacbot
/**
*
* @param ldapConnection
*/
private void closeConnection(LDAPConnection ldapConnection) {
if (ldapConnection != null) {
ldapConnection.close();
}
}
代码示例来源:origin: com.btmatthews.ldapunit/ldapunit
/**
* Disconnect from the LDAP directory server.
*/
public void disconnect() {
connection.close();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* {@inheritDoc}
*/
@Override()
public void closeInstance()
{
ldapConnection.close();
}
代码示例来源:origin: gsvigruha/cosyan
@Override
public void close() {
connection.close();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-minimal-edition
/**
* Unbinds from the server and closes the connection.
* <BR><BR>
* If this method is invoked while any operations are in progress on this
* connection, then the directory server may or may not abort processing for
* those operations, depending on the type of operation and how far along the
* server has already gotten while processing that operation. It is
* recommended that all active operations be abandoned, canceled, or allowed
* to complete before attempting to close an active connection.
*/
public void close()
{
close(NO_CONTROLS);
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Closes the connection to the server if the client forgets to do so.
*
* @throws Throwable If a problem occurs.
*/
@Override()
protected void finalize()
throws Throwable
{
conn.close();
super.finalize();
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Unbinds from the server and closes the connection.
* <BR><BR>
* If this method is invoked while any operations are in progress on this
* connection, then the directory server may or may not abort processing for
* those operations, depending on the type of operation and how far along the
* server has already gotten while processing that operation. It is
* recommended that all active operations be abandoned, canceled, or allowed
* to complete before attempting to close an active connection.
*/
@ThreadSafety(level=ThreadSafetyLevel.METHOD_NOT_THREADSAFE)
public void close()
{
close(NO_CONTROLS);
}
代码示例来源:origin: stackoverflow.com
try {
final LDAPConnection ldapConnection =
new LDAPConnection(hostname,port,bindDN,bindPassword);
final DeleteRequest deleteRequest =
new DeleteRequest("cn=entry to delete,dc=example,dc=com");
try {
LDAPResult deleteResult = connection.delete(deleteRequest);
System.out.println("The entry was successfully deleted.");
} catch (LDAPException le) {
// The delete request failed
} finally {
ldapConnection.close();
}
} catch(final LDAPException ex) {
// failed to connect to to the server
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
connection.close();
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Closes this LDAP entry source.
*
* @param abandon Indicates whether to attempt to abandon the search.
*/
private void closeInternal(final boolean abandon)
{
addToQueue(END_OF_RESULTS);
if (closed.compareAndSet(false, true))
{
if (abandon)
{
try
{
connection.abandon(asyncRequestID);
}
catch (Exception e)
{
debugException(e);
}
}
if (closeConnection)
{
connection.close();
}
}
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Creates a new LDAP connection based on the JSON specification. The
* connection will be authenticated if appropriate.
*
* @return The LDAP connection that was created.
*
* @throws LDAPException If a problem is encountered while trying to
* establish or authenticate the connection.
*/
public LDAPConnection createConnection()
throws LDAPException
{
final LDAPConnection connection = createUnauthenticatedConnection();
if (bindRequest != null)
{
try
{
connection.bind(bindRequest);
}
catch (final LDAPException le)
{
Debug.debugException(le);
connection.close();
throw le;
}
}
return connection;
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
/**
* Unbinds and disconnects from the directory server.
*
* @throws LDAPException If a problem occurs.
*/
public void disconnect()
throws LDAPException
{
authDN = null;
authPW = null;
conn.close();
if (socketFactory == null)
{
conn = new com.unboundid.ldap.sdk.LDAPConnection();
}
else
{
conn = new com.unboundid.ldap.sdk.LDAPConnection(
new LDAPToJavaSocketFactory(socketFactory));
}
}
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
connection.close();
throw le;
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
connection.close();
throw le;
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-staticsecurity-ldap
protected SearchResult execute(SearchRequest request, String bindDN, String password) {
LDAPConnection connection = null;
try {
if (allowAllSocketFactory) {
SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager());
connection = new LDAPConnection(sslUtil.createSSLSocketFactory(), serverHost, serverPort);
} else {
connection = new LDAPConnection(serverHost, serverPort);
}
if (bindDN != null) {
BindResult auth = connection.bind(bindDN, password);
if (!auth.getResultCode().isConnectionUsable()) {
log.error("Connection not usable, result code : " + auth.getResultCode());
}
}
return connection.search(request);
} catch (LDAPException le) {
String message = le.getMessage();
if (!message.startsWith("Unable to bind as user ")) {
log.error(le.getMessage(), le);
}
} catch (GeneralSecurityException gse) {
log.error(gse.getMessage(), gse);
} finally {
if (null != connection) {
connection.close();
}
}
return null;
}
代码示例来源:origin: gsvigruha/cosyan
public AuthToken auth(String username, String password, String token) throws AuthException {
String ldapHost = config.get(Config.LDAP_HOST);
try {
LDAPConnection connection = new LDAPConnection(
ldapHost,
Integer.valueOf(config.get(Config.LDAP_PORT)),
username + "@" + ldapHost,
password);
if (connection.isConnected()) {
return new LDAPToken(connection, username, token);
} else {
connection.close();
throw new AuthException("Connection not connected.");
}
} catch (LDAPException e) {
throw new AuthException(e.getExceptionMessage());
}
}
}
代码示例来源:origin: io.vertx/vertx-auth-service
private void insertTestUsers() throws LDAPException {
LDAPConnection connection = null;
try {
connection = new LDAPConnection("localhost", 10389);
// entry tim/sausages
List<Attribute> addRequest = new ArrayList<Attribute>();
addRequest.add(new Attribute("objectClass", "top"));
addRequest.add(new Attribute("objectClass", "person"));
addRequest.add(new Attribute("objectClass", "organizationalPerson"));
addRequest.add(new Attribute("objectClass", "inetOrgPerson"));
addRequest.add(new Attribute("cn", "Tim Fox"));
addRequest.add(new Attribute("sn", "Fox"));
addRequest.add(new Attribute("mail", "tim@example.com"));
addRequest.add(new Attribute("uid", "tim"));
addRequest.add(new Attribute("userPassword", "{ssha}d0M5Z2qjOOCSCQInvZHgVAleCqU5I+ag9ZHXMw=="));
connection.add("uid=tim,ou=users,dc=foo,dc=com", addRequest);
} finally {
if (connection != null) {
connection.close();
}
}
}
代码示例来源:origin: io.vertx/vertx-auth-shiro
private void insertTestUsers() throws LDAPException {
LDAPConnection connection = null;
try {
connection = new LDAPConnection("localhost", 10389);
// entry tim/sausages
List<Attribute> addRequest = new ArrayList<>();
addRequest.add(new Attribute("objectClass", "top"));
addRequest.add(new Attribute("objectClass", "person"));
addRequest.add(new Attribute("objectClass", "organizationalPerson"));
addRequest.add(new Attribute("objectClass", "inetOrgPerson"));
addRequest.add(new Attribute("cn", "Tim Fox"));
addRequest.add(new Attribute("sn", "Fox"));
addRequest.add(new Attribute("mail", "tim@example.com"));
addRequest.add(new Attribute("uid", "tim"));
addRequest.add(new Attribute("userPassword", "{ssha}d0M5Z2qjOOCSCQInvZHgVAleCqU5I+ag9ZHXMw=="));
connection.add("uid=tim,ou=users,dc=foo,dc=com", addRequest);
} finally {
if (connection != null) {
connection.close();
}
}
}
代码示例来源:origin: de.otto.edison/edison-togglz
} finally {
if (ldapConnection != null) {
ldapConnection.close();
代码示例来源:origin: com.unboundid/unboundid-ldapsdk-commercial-edition
connection.close();
throw le;
内容来源于网络,如有侵权,请联系作者删除!