I have rewritten the the program to connect to LDAP over SSL. Here is the
latest code and problem.
Source Code:
public static void main(String[] args) {
String str_ldapsHost = "ldap.openldap.org";
int i_ldapsPort = 636;
String str_baseDN = "cacertificate=New,o=ascertia.com.pk";
performLdapSearchUsingNetscape(str_ldapsHost, i_ldapsPort, str_baseDN,
true);
// performLdapSearchUsingNovell(str_ldapsHost, i_ldapsPort, str_baseDN,
true);
}
public static void performLdapSearchUsingNetscape(String a_strHost, int
a_iPort, String a_strBaseDN, boolean a_bUseSSL){
try{
netscape.ldap.LDAPConnection obj_connection = null;
if( a_bUseSSL ){
System.out.println("Adding Security Providers ...");
java.security.Security.addProvider(new
com.sun.net.ssl.internal.ssl.Provider());
System.getProperties().put("java.protocol.handler.pkgs","com.sun.net.ssl.int
ernal.www.protocol");
System.out.println("Connecting to LDAPS server
"+a_strHost+":"+a_iPort);
netscape.ldap.factory.JSSESocketFactory obj_sslSocketFactory = new
netscape.ldap.factory.JSSESocketFactory(null);
obj_connection = new
netscape.ldap.LDAPConnection(obj_sslSocketFactory);
}
else{
System.out.println("Connecting to LDAP server
"+a_strHost+":"+a_iPort);
obj_connection = new netscape.ldap.LDAPConnection();
}
obj_connection.connect( a_strHost, a_iPort );
System.out.println("Connection to LDAP server
"+a_strHost+":"+a_iPort+" is successful");
System.out.println("Perfoming LDAP search ...");
netscape.ldap.LDAPSearchResults obj_ldapResults =
obj_connection.search(a_strBaseDN, netscape.ldap.LDAPv2.SCOPE_SUB,
"objectclass=*", null, false);
System.out.println("LDAP Results Found :
"+obj_ldapResults.getCount());
}
catch (Exception ex) {
ex.printStackTrace();
}
}
Here is the output:
Adding Security Providers ...
Connecting to LDAPS server ldap.openldap.org:636
Connection to LDAP server ldap.openldap.org:636 is successful
Perfoming LDAP search ...
netscape.ldap.LDAPException: The connection is not available (80); Unknown
error
at netscape.ldap.LDAPConnection.sendRequest(LDAPConnection.java:1809)
at netscape.ldap.LDAPConnection.search(LDAPConnection.java:2520)
at netscape.ldap.LDAPConnection.search(LDAPConnection.java:2402)
at
com.ascertia.ldapclient.ASC_LDAPConnector.performLdapSearchUsingNetscape(ASC
_LDAPConnector.java:64)
at
com.ascertia.ldapclient.ASC_LDAPConnector.main(ASC_LDAPConnector.java:11)
I have also tested the same program with my local Netscape Directory Server
v4.2, but got the same results. Any help or ideas would be highly
appreciated.
Thanx.
Regards,
Yasir
_______________________________________________
mozilla-directory mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-directory