ldapConnection.bind(LDAPConnection.LDAP_V3, userDN, passwordBytes);
private LDAPConnection getConnection() throws LDAPException, UnsupportedEncodingException { // LDAPSocketFactory ssf; // Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); // String path ="C:\\j2sdk1.4.2_09\\jre\\lib\\security\\cacerts"; //op("the trustStore: " + System.getProperty("javax.net.ssl.trustStore")); // System.setProperty("javax.net.ssl.trustStore", path); // op(" reading the strustStore: " + System.getProperty("javax.net.ssl.trustStore")); // ssf = new LDAPJSSESecureSocketFactory(); // LDAPConnection.setSocketFactory(ssf); LDAPConnection lc = new LDAPConnection(); lc.connect(ldapHost, ldapPort); // bind to the server lc.bind(ldapVersion, loginDN, password.getBytes("UTF8")); // tbd // LDAPConnection pooling here? // return lc; }
public void bind(int i, String s, String s1, LDAPConstraints ldapconstraints) throws LDAPException { bindAttempted = true; super.bind(i, s, s1, ldapconstraints); }
public void bind(String s, String s1) throws LDAPException { bindAttempted = true; super.bind(s, s1); }
public void bind(int i, String s, byte[] abyte0) throws LDAPException { bindAttempted = true; super.bind(i, s, abyte0); }
public void bind(String s, String s1, String[] as, Map map, Object obj) throws LDAPException { bindAttempted = true; super.bind(s, s1, as, map, obj); }
public void bind(int i, String s, byte[] abyte0, LDAPConstraints ldapconstraints) throws LDAPException { bindAttempted = true; super.bind(i, s, abyte0, ldapconstraints); }
public LDAPResponseQueue bind(int i, String s, byte[] abyte0, LDAPResponseQueue ldapresponsequeue) throws LDAPException { bindAttempted = true; return super.bind(i, s, abyte0, ldapresponsequeue); }
public void bind(int i, String s, String s1) throws LDAPException { bindAttempted = true; super.bind(i, s, s1); }
public void bind(String s, String s1, LDAPConstraints ldapconstraints) throws LDAPException { bindAttempted = true; super.bind(s, s1, ldapconstraints); }
public void bind(String s, String s1, Map map, Object obj, LDAPConstraints ldapconstraints) throws LDAPException { bindAttempted = true; super.bind(s, s1, map, obj, ldapconstraints); }
public LDAPResponseQueue bind(int i, String s, byte[] abyte0, LDAPResponseQueue ldapresponsequeue, LDAPConstraints ldapconstraints) throws LDAPException { bindAttempted = true; return super.bind(i, s, abyte0, ldapresponsequeue, ldapconstraints); }
public void bind(String s, String s1, Map map, Object obj) throws LDAPException { bindAttempted = true; super.bind(s, s1, map, obj); }
public void bind(String s, String s1, String[] as, Map map, Object obj, LDAPConstraints ldapconstraints) throws LDAPException { bindAttempted = true; super.bind(s, s1, as, map, obj, ldapconstraints); }
/** * Bind to LDAP server. * * @param loginDN the user DN to connect to LDAP server. * @param password the password to connect to LDAP server. * @throws UnsupportedEncodingException error when converting provided password to UTF-8 table. * @throws LDAPException error when trying to bind. */ public void bind(String loginDN, String password) throws UnsupportedEncodingException, LDAPException { LOGGER.debug("Binding to LDAP server with credentials login=[{}]", loginDN); // authenticate to the server this.connection.bind(LDAPConnection.LDAP_V3, loginDN, password.getBytes("UTF8")); }
private void bind(LDAPConnection conn, String dn, String pw) throws LDAPException { if ( log.isDebugEnabled() ) { log.debug("bind(): binding [dn = " + dn + "]"); } try { conn.bind(LDAPConnection.LDAP_V3, dn, pw.getBytes("UTF8")); } catch ( UnsupportedEncodingException e ) { throw new RuntimeException("Failed to encode user password", e); } }
// exception handling not shown LDAPConnection ldapConnection = new LDAPConnection(hostname,port); BindRequest bindRequest = new SimpleBindRequest(username,password); BindResult bindResult = ldapConnection.bind(bindRequest); if(bindResult.getResultCode().equals(ResultCode.SUCCESS)) { /// successful authentication } ldapConnection.close();
LDAPConnection connection = new LDAPConnection( new LDAPJSSEStartTLSFactory() ); connection.connect(hostname, port); connection.startTLS(); connection.bind(LDAPConnection.LDAP_V3, username+"@"+domain, password.getBytes());
// exception handling is not shown final String dn = ....; final byte[] password = ....; final BindRequest bindRequest = new SimpleBindRequest(dn,password); final LDAPConnection ldapConnection = new LDAPConnection(hostname,port); final BindResult bindResult = ldapConnection.bind(bindRequest); final ResultCode resultCode = bindResult.getResultCode(); if(resultCode.equals(ResultCode.SUCCESS)) { // user is authenticated } ldapConnection.close();
public static LDAPConnection getNewSSLConnection(String address, int port, BindRequest bindRequest) throws LDAPException, GeneralSecurityException { SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager()); SSLSocketFactory sslSocketFactory = sslUtil.createSSLSocketFactory(); LDAPConnection ldc = new LDAPConnection(sslSocketFactory); ldc.connect(address, port); ldc.bind(bindRequest); return ldc; }