/**
  * Starts an embedded LDAP server of the specified port.
  *
  * @param port The desired port the LDAP server should listen on.
  * @return The actual port the LDAP server is listening on.
  * @throws Exception Thrown if a failure occurs.
  */
 public int setupLdap(int port) throws Exception {
   URL usersUrl = getResourceUrl("users.ldif");
   ldapTransport = new TcpTransport(port);
   ldap =
       new SimpleLdapDirectoryServer(
           "dc=hadoop,dc=apache,dc=org", new File(usersUrl.toURI()), ldapTransport);
   ldap.start();
   log.info("LDAP port = " + port);
   return port;
 }
 public static void setupLdap() throws Exception {
   URL usersUrl = getResourceUrl("users.ldif");
   int port = findFreePort();
   ldapTransport = new TcpTransport(port);
   ldap =
       new SimpleLdapDirectoryServer(
           "dc=hadoop,dc=apache,dc=org", new File(usersUrl.toURI()), ldapTransport);
   ldap.start();
   LOG.info("LDAP port = " + ldapTransport.getPort());
 }