Hi all,

I am new to LDAP development but I am getting up to speed now. My
question is that I am trying the examples that come with the library and
each time that I run the example nothing seems to happen. All that
happen is the first lines of the sample. No connections seems to happen
and after debugging I found out that nothing is working after the first
13 lines. Can someone tell me what I need to do to make the other lines
work? Your help is appreciated.

One of the sample codes is pasted below. Thank you


import com.novell.ldap.*;


import java.io.UnsupportedEncodingException;





public class VerifyPassword


{


public static void main( String[] args )


{


if (args.length != 5) {


System.out.println("Usage: java VerifyPassword <host
name>"


+ " <login dn> <password> <object dn>\n"


+ " <test password>");


System.out.println("Example: java VerifyPassword Acme.com "


+ "\"cn=Admin,o=Acme\" secret\n"


+ " \"cn=JSmith,ou=Sales,o=Acme\"
testPassword");


System.exit(0);


}





int ldapPort = LDAPConnection.DEFAULT_PORT;


int ldapVersion = LDAPConnection.LDAP_V3;


String ldapHost = args[0];


String loginDN = args[1];


String password = args[2];


String objectDN = args[3];


String testPassword = args[4];


LDAPConnection lc = new LDAPConnection();





try {


// connect to the server


lc.connect( ldapHost, ldapPort );





// authenticate to the server


lc.bind( ldapVersion, loginDN, password.getBytes("UTF8")
);





LDAPAttribute attr = new LDAPAttribute(


"userPassword",
testPassword );


boolean correct = lc.compare( objectDN, attr );





System.out.println( correct ? "The password is correct.":


"The password is
incorrect.\n");





// disconnect with the server


lc.disconnect();


}


catch( LDAPException e ) {


if ( e.getResultCode() == LDAPException.NO_SUCH_OBJECT ) {


System.err.println( "Error: No such entry" );


} else if ( e.getResultCode() ==


LDAPException.NO_SUCH_ATTRIBUTE
) {


System.err.println( "Error: No such attribute" );


} else {


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


}


}


catch( UnsupportedEncodingException e ) {


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


}


System.exit(0);


}


}


--
olasamuel
------------------------------------------------------------------------
olasamuel's Profile: http://forums.novell.com/member.php?userid=70243
View this thread: http://forums.novell.com/showthread.php?t=393868