0

I am writing a unit test for my code and for testing purpose I am using unboundsId's IN memory LDAP server. I created and conntected to inmemory server and after That i want to perform a sync request but server is saying "InMemory LDAP server do not support contentSyncRequestControl". I looked in to server API docs there are number of controlls. I tried to print OIDs of controls which are supported and The OID for contentSyncRequestControl is not present. so My Question is how to enable or add controlls to inMemory LDAP Server?? Look the following code for ref.

public class InMemoryLDAPServer {
    private Logger logger = LoggerFactory.getLogger(InMemoryLDAPServer.class);

    private InMemoryDirectoryServer mServer;
    final String DEFAULT_INMEMORY_HOST = "localhost";
    final int DEFAULT_INMEMORY_PORT = 5389;
    final String LDAP_LISTENER_NAME = "LDAP_TEST_SERVER";
    final String INMEMORY_BASE = "dc=Contoso,dc=net";
    final String INMEMORY_DOMAIN = "Contoso.net";
    final String INMEMORY_USER = "uid=TestAdmin";
    final String INMEMORY_PASS = "password";


    public void start(int port) {
        try {

            InMemoryDirectoryServerConfig config =
                 new InMemoryDirectoryServerConfig(INMEMORY_BASE);
            config.setGenerateOperationalAttributes(true);
            config.addAdditionalBindCredentials(INMEMORY_USER, INMEMORY_PASS);
            config.setListenerConfigs(InMemoryListenerConfig.createLDAPConfig(LDAP_LISTENER_NAME, port));


            mServer = new InMemoryDirectoryServer(config);
            URI ldifFixture= InMemoryLDAPServer.class.getResource("/Contoso_rootdse_open.ldif").toURI();
            mServer.importFromLDIF(true, new LDIFReader(new File(ldifFixture)));


            mServer.startListening(LDAP_LISTENER_NAME); 
            // I tried here to check which controlls are supported
//The OID (1.3.6.1.4.1.4203.1.9.1.1) for the sync request control.
            LDAPConnection con = mServer.getConnection();
            RootDSE rootDSE = con.getRootDSE();
            String[] oids = rootDSE.getSupportedControlOIDs();

            for(int i=0; i<oids.length; i++){
                System.out.println(oids[i]);

            }
            con.close();

        } catch(Exception exception) {
            logger.error("Failed to start in memory ldap server", exception);
        }


    }

    public void start() {
        start(DEFAULT_INMEMORY_PORT);
    }

    public void stop() {
        try {
        mServer.shutDown(LDAP_LISTENER_NAME, true);
        } catch(Exception ex) {
            ex.printStackTrace();
        }
    }
}

result

here are the default supported control OIDs .

1.2.840.113556.1.4.1413
1.2.840.113556.1.4.319
1.2.840.113556.1.4.473
1.2.840.113556.1.4.805
1.3.6.1.1.12
1.3.6.1.1.13.1
1.3.6.1.1.13.2
1.3.6.1.1.21.2
1.3.6.1.1.22
1.3.6.1.4.1.7628.5.101.1
2.16.840.1.113730.3.4.12
2.16.840.1.113730.3.4.16
2.16.840.1.113730.3.4.18
2.16.840.1.113730.3.4.2
2.16.840.1.113730.3.4.9

Ref to API doc: https://docs.ldap.com/ldap-sdk/docs/javadoc/index.html

Kindly Help me to proper configuration please.

user207421
  • 305,947
  • 44
  • 307
  • 483
Mubasher
  • 943
  • 1
  • 13
  • 36

1 Answers1

1

There isn't really a good way to do this. You can add support for custom extended operations and SASL mechanisms, because in those cases the custom code will perform all of the processing. But a control actually changes the way that the server processes the operation, so it's got to be integrated into the core processing that the server performs.

However, if the control you want to use is simple enough that it could be supported by not changing the core processing for the operation but just altering the request or response, then you should be able to accomplish that by creating a custom InMemoryOperationInterceptor (although it wouldn't show up in the root DSE's set of supported controls, unless you also intercepted requests to retrieve the root DSE and injected the additional OID in there).

What control(s) are you interested in? Are they standard or proprietary? The in-memory directory server is intended to be a generic, standards-compliant server, and it's not really appropriate for it to include proprietary elements. But if there's a standard control that it doesn't currently support but might be useful, then we could consider adding direct support for it.

Neil Wilson
  • 1,706
  • 8
  • 4
  • As I mentioned in question, I want content sync requests, content sync done and content sync info control. So that I can perform sync operations in testing. Or is there any way by which I can intercept "sync request" and then returns directry contents manually. Any code example will be helpfull. – Mubasher Feb 06 '15 at 04:11