UnboundID and SOfterra

General Discussion about LDAP Administrator

Moderator: Support

UnboundID and SOfterra

Postby Gilles » Tue Oct 09, 2012 2:10 pm

Hello,

I'm trying to create a LDAP Listener with UnboundID that can bind and search in a LDAP server. The listener work, but when I want to connect with Softerra, i've some errors.

First, Softerra tell me that : "Error loading RootDSE entry from LocalHost:6666
And this when I want to fetch base DNs : Error occured while fetching base DNs. Maybe LDAP v.2 server or connection problem.

EDIT: I'm with Softerra LDAP Browser 4.5

I don't really know how to solve errors like that, but I think i might return something bad or something is missing. Here is the code of my LDAP listener request Handler :
Code: Select all
package net.nantes.unboundid;

import java.util.Collections;
import java.util.List;

import com.unboundid.asn1.ASN1OctetString;
import com.unboundid.ldap.listener.LDAPListenerClientConnection;
import com.unboundid.ldap.listener.LDAPListenerRequestHandler;
import com.unboundid.ldap.protocol.AddRequestProtocolOp;
import com.unboundid.ldap.protocol.BindRequestProtocolOp;
import com.unboundid.ldap.protocol.BindResponseProtocolOp;
import com.unboundid.ldap.protocol.CompareRequestProtocolOp;
import com.unboundid.ldap.protocol.DeleteRequestProtocolOp;
import com.unboundid.ldap.protocol.ExtendedRequestProtocolOp;
import com.unboundid.ldap.protocol.LDAPMessage;
import com.unboundid.ldap.protocol.ModifyDNRequestProtocolOp;
import com.unboundid.ldap.protocol.ModifyRequestProtocolOp;
import com.unboundid.ldap.protocol.SearchRequestProtocolOp;
import com.unboundid.ldap.protocol.SearchResultDoneProtocolOp;
import com.unboundid.ldap.sdk.Control;
import com.unboundid.ldap.sdk.LDAPConnection;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.ResultCode;
import com.unboundid.ldap.sdk.RootDSE;
import com.unboundid.ldap.sdk.SearchResult;
import com.unboundid.ldap.sdk.SearchScope;


public class MyLDAPListenerRequestHandler extends LDAPListenerRequestHandler {

     private SearchResultDoneProtocolOp searchResultDoneProtocolOp;
   
     public MyLDAPListenerRequestHandler()
     {
       this(ResultCode.SUCCESS, null, null, null);
     }
    
     public MyLDAPListenerRequestHandler(ResultCode resultCode, String matchedDN, String diagnosticMessage, List<String> referralURLs) {
        int rc = resultCode.intValue();
        System.out.println("matchedDN: " + matchedDN + " + ResultCode: " + resultCode + " + diagnosticMessage: " + diagnosticMessage);
        searchResultDoneProtocolOp = new SearchResultDoneProtocolOp(rc, matchedDN,
                  diagnosticMessage, referralURLs);
     }

   @Override
   public LDAPListenerRequestHandler newInstance(
         LDAPListenerClientConnection arg0) throws LDAPException {
         System.out.println("New Instance.");
      return this;
   }

   @Override
   public LDAPMessage processAddRequest(int arg0, AddRequestProtocolOp arg1,
         List<Control> arg2) {
      System.out.println("There is an add here.");
      return null;
   }

   @Override
   public LDAPMessage processBindRequest(int arg0, BindRequestProtocolOp arg1,
         List<Control> arg2) {
      System.out.println("Binding ...");
      String login = arg1.getBindDN();
      ASN1OctetString password = arg1.getSimplePassword();
      try {
         LDAPConnection connection = new LDAPConnection("192.168.56.2", 389, login, password.toString());
         System.out.println(connection.getRootDSE());
      } catch (LDAPException e) {
         e.printStackTrace();
      }
      Connect c = new Connect();
      System.out.println(c.connect(login,password));
      LDAPMessage message = new LDAPMessage(arg0, arg1, arg2);
      BindResponseProtocolOp protocolOp =
               message.getBindResponseProtocolOp();
      LDAPMessage message2 = new LDAPMessage(arg0, protocolOp, arg2);
      return message2;
   }

   @Override
   public LDAPMessage processCompareRequest(int arg0,
         CompareRequestProtocolOp arg1, List<Control> arg2) {
      System.out.println("There is an compare here.");
      return null;
   }

   @Override
   public LDAPMessage processDeleteRequest(int arg0,
         DeleteRequestProtocolOp arg1, List<Control> arg2) {
      System.out.println("There is an delete here.");
      return null;
   }

   @Override
   public LDAPMessage processExtendedRequest(int arg0,
         ExtendedRequestProtocolOp arg1, List<Control> arg2) {
      System.out.println("There is an extended request here.");
      return null;
   }

   @Override
   public LDAPMessage processModifyDNRequest(int arg0,
         ModifyDNRequestProtocolOp arg1, List<Control> arg2) {
      System.out.println("There is a modifyDN request here.");
      return null;
   }

   @Override
   public LDAPMessage processModifyRequest(int arg0,
         ModifyRequestProtocolOp arg1, List<Control> arg2) {
      System.out.println("There is a modify request here.");
      return null;
   }

   @Override
   public LDAPMessage processSearchRequest(int arg0,
         SearchRequestProtocolOp arg1, List<Control> arg2) {
      try {
         LDAPConnection connection = new LDAPConnection("192.168.56.2", 389, "cn=admin,dc=nantes,dc=net", "*******");
         System.out.println("Connected to LDAP server, searching Naming Context...");
         RootDSE rootDSE = connection.getRootDSE();
         SearchResult test = connection.search("dc=nantes,dc=net", SearchScope.SUB, "(ObjectClass=*)", (String[])null);
         System.out.println("getDSE retrieved: " + rootDSE);
         System.out.println(test.getSearchEntries());
         
      } catch (LDAPException e) {
         e.printStackTrace();
      }
      return new LDAPMessage(arg0, searchResultDoneProtocolOp,
               Collections.<Control>emptyList());
   }

}


and here is the "main" code for Listener:

Code: Select all
public class MyConnection {

   private LDAPListener listener;

   public MyConnection(){
   }
   
   public ResultCode CreateLdapServer() throws LDAPException {
      MyLDAPListenerRequestHandler requestHandler = new MyLDAPListenerRequestHandler();
      LDAPListenerConfig config =
               new LDAPListenerConfig(6666, requestHandler);
      
         try
         {
           config.setListenAddress(
                InetAddress.getByName("localhost"));
         }
         catch (final Exception e)
         {
           System.err.println("Unable to create the listen server.");
           return ResultCode.PARAM_ERROR;
         }
      
       listener = new LDAPListener(config);
      
       try
       {
         listener.startListening();
         System.out.println("Serveur is listening ...");
       }
       catch (IOException e)
       {
          System.err.println("Unable to start listening.");
         return ResultCode.LOCAL_ERROR;
       }
       System.out.println(listener.getListenAddress() + " " + listener.getListenPort());

      return ResultCode.SUCCESS;
   }
   
   public static void main(String[] args) throws LDAPException {
      MyConnection connect = new MyConnection();
      connect.CreateLdapServer();
   }
}

thanks for your help !
Last edited by Gilles on Wed Oct 10, 2012 7:52 am, edited 1 time in total.
Gilles
 
Posts: 3
Joined: Tue Oct 09, 2012 2:03 pm

Re: UnboundID and SOfterra

Postby Support » Tue Oct 09, 2012 5:53 pm

Hi.
Could you please specify, what type of LDAP server (version\vendor) do you use.

Also, if it is LDAP v.2 server, you should enable LDAP v.2 compatibility mode. To do this:
1) Right click on your LDAP server profile and in the opened context menu select 'Properties'.
2) Select 'LDAP Settings' tab
3) Press 'Advanced' button
4) Select 'Miscellanious' tab
5) Check 'Force compatibility with the LDAP v.2 protocol'
Support
 
Posts: 886
Joined: Sun Aug 12, 2001 12:00 am

Re: UnboundID and SOfterra

Postby Gilles » Wed Oct 10, 2012 7:09 am

Hi,

Thanks for your answer. I have an OpenLDAP server on a Debian Virtual Machine, it works well and I have LDAP V.3, i'm pretty sure of it. I'm going to try to enable LDAP V.2.

EDIT: In case, I added the code where I create the listener (but I don't think the problem is here).
EDIT2: Forcing LDAP V.2 doesn't fix the problem.

Gilles.
Gilles
 
Posts: 3
Joined: Tue Oct 09, 2012 2:03 pm

Re: UnboundID and SOfterra

Postby kirill.kovalenko » Wed Oct 10, 2012 9:01 am

Apparently your custom server instance does not expose RooDSE entry, which should never happen for a real LDAP Server. LDAP Administrator (and other LDAP clients too I think) always expect RootDSE to exist and be available.
kirill.kovalenko
 
Posts: 9
Joined: Mon Oct 08, 2012 1:32 pm

Re: UnboundID and SOfterra

Postby Gilles » Wed Oct 10, 2012 2:35 pm

thanks kirill.kovalenko for your answer.

But have you any idea/advice to expose the RootDSE ? I don't really know how to do it.
Gilles
 
Posts: 3
Joined: Tue Oct 09, 2012 2:03 pm

Re: UnboundID and SOfterra

Postby kirill.kovalenko » Mon Oct 15, 2012 10:53 am

Gilles wrote:have you any idea/advice to expose the RootDSE ? I don't really know how to do it.

Nope, I've never worked with Unbound SDK. Do they provide examples?
kirill.kovalenko
 
Posts: 9
Joined: Mon Oct 08, 2012 1:32 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron