public LdapNetworkConnection connect(LdapConnectionConfig config) throws LdapException { final LdapNetworkConnection connection = new LdapNetworkConnection(config); connection.setTimeOut(connectionTimeout);
/** * Creates a new LdapDao. Its connection will use the given parameters. * */ public LdapDao(String host, int port) { this.connection = new LdapNetworkConnection(host, port); }
/** * Creates a new instance of Dsmlv2Engine. * * @param host the server host * @param port the server port * @param user the server admin Dn * @param password the server admin's password */ public Dsmlv2Engine( String host, int port, String user, String password ) { this.user = user; this.password = password; connection = new LdapNetworkConnection( host, port ); }
/** * Gets a LDAP connection instance on a server. We won't bind on the server. * * @param ldapServer The server we want to connect to * @return A LdapConnection instance if we got one * @throws LdapException If the connection cannot be created */ public static LdapConnection getLdapConnection( LdapServer ldapServer ) throws LdapException { LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ); return connection; }
@Override public void start(BundleContext context) throws Exception { connection = new LdapNetworkConnection("localhost", 10389); connection.connect(); }
private DlabLdapConnection getConnection(LdapConnectionPool connectionPool) { return ldapUseConnectionPool ? new ReturnableConnection(connectionPool) : new SimpleConnection(new LdapNetworkConnection(connConfig)); }
/** * Gets an anonymous LdapNetworkConnection * * @param host The server to connect to * @param port The port to connect on * @return A LdapNetworkConnection instance * @exception LdapException If the connection could not be established. */ public static LdapConnection getAnonymousNetworkConnection( String host, int port ) throws LdapException { LdapConnection connection = new LdapNetworkConnection( host, port ); connection.bind(); OPEN_CONNECTIONS.add( connection ); return connection; }
/** * {@inheritDoc} */ @Override public LdapConnection newUnboundLdapConnection() { if ( apiService == null ) { return configureConnection( new LdapNetworkConnection( connectionConfig ) ); } else { return configureConnection( new LdapNetworkConnection( connectionConfig, apiService ) ); } }
/** * {@inheritDoc} */ @Override public LdapConnection newUnboundLdapConnection() { if ( apiService == null ) { return configureConnection( new LdapNetworkConnection( connectionConfig ) ); } else { return configureConnection( new LdapNetworkConnection( connectionConfig, apiService ) ); } }
/** * Gets an anonymous LdapNetworkConnection * * @param host The server to connect to * @param port The port to connect with * @return A LdapNetworkConnection instance * @exception LdapException If the connection could not be established. */ public static LdapConnection getAnonymousNetworkConnection( String host, int port ) throws LdapException { LdapConnection connection = new LdapNetworkConnection( host, port ); connection.bind(); return connection; }
/** * {@inheritDoc} */ @Override public LdapConnection newUnboundLdapConnection() { if ( apiService == null ) { return configureConnection( new LdapNetworkConnection( connectionConfig ) ); } else { return configureConnection( new LdapNetworkConnection( connectionConfig, apiService ) ); } }
/** * {@inheritDoc} */ public LdapConnection makeObject() throws LdapException { LdapNetworkConnection connection = config.isUseTls() ? new TlsGuardingConnection(config) : new LdapNetworkConnection(config); connection.connect(); log.debug("creating new connection: {}", connection); return connection; }
/** * Creates a new {@link LdapNetworkConnection} and authenticates as admin user. * The caller is responsible for closing the connection, use closeConnection(). * * @param ldapServer the LDAP server instance, used to obtain the port used * @return the created connection * @throws LdapException the LDAP exception */ public static LdapNetworkConnection createAdminConnection( LdapServer ldapServer ) throws LdapException { LdapNetworkConnection conn = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ); conn.bind( DEFAULT_ADMIN, DEFAULT_PASSWORD ); return conn; }
/** * Gets a LDAP connection instance on a server. We will bind as Admin * * @param ldapServer The server we want to connect to * @return A LdapConnection instance if we got one * @throws LdapException If the connection cannot be created */ public static LdapConnection getAdminConnection( LdapServer ldapServer ) throws LdapException { LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ); connection.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" ); return connection; } }
@JsonIgnore public LdapConnection getConnection(final IOUtils.CloseableContext context, final Long timeOut) throws LdapException { LdapConnection connection; if (connectionPool != null) connection = connectionPool.getConnection(); else connection = new LdapNetworkConnection(config); if (context != null) context.add(connection); if (timeOut != null) connection.setTimeOut(timeOut); return connection; }
/** * Gets a LdapNetworkConnection bound to the Admin user (uid=admin,ou=system). * * @param ldapServer The LdapServer to be connected to * @return A LdapNetworkConnection instance * @exception LdapException If the connection could not be established. */ public static LdapConnection getAdminNetworkConnection( LdapServer ldapServer ) throws LdapException { LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ); connection.setTimeOut( 30000L ); connection.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" ); OPEN_CONNECTIONS.add( connection ); return connection; }
/** * Gets an anonymous LdapNetworkConnection * * @param ldapServer The LDAP server we want to connect to * @return A LdapNetworkConnection instance * @exception LdapException If the connection could not be established. */ public static LdapConnection getAnonymousNetworkConnection( LdapServer ldapServer ) throws LdapException { LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() ); connection.setTimeOut( 0L ); connection.bind(); return connection; } }
protected synchronized LdapConnection getConn() { return new LdapNetworkConnection(cfg.getConnection().getHost(), cfg.getConnection().getPort(), cfg.getConnection().isTls()); }
/** * Start the connection for the initialize() */ private void startConnection() throws LdapException { if (isLdapNetworkConnection == true) { this.connection = new LdapNetworkConnection(getConfig().getString("host"), getConfig().getInt("port")); } connection.bind(getConfig().getString("admin_dn"), getConfig().getString("admin_pw")); }
/** * Start the connection for the initialize() */ private void startConnection() throws LdapException { if (isLdapNetworkConnection == true) { this.connection = new LdapNetworkConnection(getConfig().getString("host"), getConfig().getInt("port")); } connection.bind(getConfig().getString("admin_dn"), getConfig().getString("admin_pw")); }