/** start the LDAP server */
  private void startLdap(LdapServerBean ldapServerBean, DirectoryService directoryService)
      throws Exception {
    LOG.info("Starting the LDAP server");
    long startTime = System.currentTimeMillis();

    ldapServer = ServiceBuilder.createLdapServer(ldapServerBean, directoryService);

    if (ldapServer == null) {
      LOG.info(
          "Cannot find any reference to the LDAP Server in the configuration : the server won't be started");
      return;
    }

    // printBanner( BANNER_LDAP );

    ldapServer.setDirectoryService(directoryService);

    // And start the server now
    try {
      ldapServer.start();
    } catch (Exception e) {
      LOG.error("Cannot start the server : " + e.getMessage());
    }

    LOG.info(
        "LDAP server: started in {} milliseconds", (System.currentTimeMillis() - startTime) + "");
  }
예제 #2
0
  public void afterPropertiesSet() throws Exception {
    if (workingDir == null) {
      String apacheWorkDir = System.getProperty("apacheDSWorkDir");

      if (apacheWorkDir == null) {
        apacheWorkDir = "apacheds-spring-security";
      }

      setWorkingDirectory(new File(apacheWorkDir));
    }

    server = new LdapServer();
    server.setDirectoryService(service);
    server.setTransports(new TcpTransport(port));
    start();
  }
  public void start() throws Exception {
    // Initialize the LDAP service
    service = new DefaultDirectoryService();

    service.setWorkingDirectory(workingDir);

    // Disable the ChangeLog system
    service.getChangeLog().setEnabled(false);
    service.setDenormalizeOpAttrsEnabled(true);

    Partition ipponPartition = addPartition("ippon", "dc=ippon,dc=fr");

    // And start the service
    service.startup();

    // Inject the ippon root entry if it does not already exist
    try {
      service.getAdminSession().lookup(ipponPartition.getSuffixDn());
      System.out.printf("Root %s found ! %n", ipponPartition.getSuffixDn());
    } catch (LdapNameNotFoundException lnnfe) {
      System.out.printf("Root %s not found ! creating it ... %n", ipponPartition.getSuffixDn());

      LdapDN dnippon = new LdapDN("dc=ippon,dc=fr");
      ServerEntry entryippon = service.newEntry(dnippon);
      entryippon.add("objectClass", "top", "domain", "extensibleObject");
      entryippon.add("dc", "ippon");
      service.getAdminSession().add(entryippon);

      System.out.printf("Importing some data ... %n", ipponPartition.getSuffixDn());
      InputStream is = this.getClass().getResource("ipponTestLdapExport.ldif").openStream();
      LdifReader ldifReader = new LdifReader(is);
      for (LdifEntry entry : ldifReader) {
        injectEntry(entry, service);
      }
      is.close();
    }

    // service LDAP :
    server = new LdapServer();
    // int serverPort = 10389;
    int serverPort = 389;
    server.setTransports(new TcpTransport(serverPort));
    server.setDirectoryService(service);

    server.start();
  }
 private void startServer() throws Exception {
   service.startup();
   server = new LdapServer();
   server.setTransports(new TcpTransport(10389));
   server.setDirectoryService(service);
 }