Hi Everyone,

I am trying to play with java ldap classes for the first time. I was able
to connect and see the directories using openldap browser client. I used
the same DN, host and credentials in the LDAPList code and I keep getting
this bind error. When I check for the connection.isbound(), it returns
true....

Any help is appreciated.

thanks,
-Anou


In the console....
ref: true
Bind :true
Error: LDAPException: Operations Error (1) Operations Error
LDAPException: Server Message: 00000000: LdapErr: DSID-0C090627, comment:
In order to perform this operation a successful bind must be completed on
the connection., data 0, vece



The code is.... copy of LDAPList...
public class LDAPList
{
public static final int LENGTH = 42;
public static final int BITS = 336;
public static final int BITSOFFSET = 14;
public static Date date = new Date();
public static String locale = date.toString();
public static void main( String[] args )
{
int ldapPort = LDAPConnection.DEFAULT_PORT;
int searchScope = LDAPConnection.SCOPE_ONE;
int ldapVersion = LDAPConnection.LDAP_V3;;
boolean attributeOnly = false;

String attrs[] = {LDAPConnection.NO_ATTRS};
String ldapHost = "host.com";
String loginDN = "CN=service-ldapquery,OU=Service
Accounts,DC=x1,DC=x2,DC=x3,DC=com";
String password = "xyz";
String searchBase = "DC=x1,DC=x2,DC=x3,DC=com";
String searchFilter = "(objectClass=*)";

LDAPConnection lc = new LDAPConnection();
LDAPSearchConstraints ldapConstraints = new LDAPSearchConstraints
(20000, // client
// timeout
20000, // server timeout
LDAPSearchConstraints.DEREF_NEVER, // alias dereference
100, // max search results
true, // referral following
1000, // results batch size
null, // referral handler
10); //ReferralHopLimit
//LDAPConstraints ldapConstraints = new LDAPConstraints();
ldapConstraints.setReferralFollowing(true);
lc.setConstraints(ldapConstraints);
//ldapConstraints.
System.out.println("ref: " + lc.getConstraints
().getReferralFollowing());
try {
// connect to the server
lc.connect( ldapHost, ldapPort );
// bind to the server
lc.bind( ldapVersion, loginDN, password.getBytes("UTF8") );
System.out.println(" Bind :" + lc.isBound() );
LDAPSearchResults searchResults =
lc.search( searchBase, // container to search

searchScope, // search scope

searchFilter, // search filter

attrs, // "1.1" returns entry name
only

attributeOnly); // no attributes are returned
// print out all the objects

while ( searchResults.hasMore()) {

LDAPEntry nextEntry = null;

try {

nextEntry = searchResults.next();

}
catch(LDAPException e) {
System.out.println("Error: " + e.toString());
continue;
}
System.out.println("\n" + nextEntry.getDN());
}

// disconnect with the server
lc.disconnect();
}

catch( LDAPException e ) {

System.out.println( "Error: " + e.toString() );

}

catch( UnsupportedEncodingException e ) {

System.out.println( "Error: " + e.toString() );

}

System.exit(0);

}