/ Published in: Java
Expand |
Embed | Plain Text
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import com.unboundid.ldap.listener.InMemoryDirectoryServer; import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig; import com.unboundid.ldap.sdk.LDAPConnection; import com.unboundid.ldap.sdk.LDAPException; import com.unboundid.ldap.sdk.SearchResultEntry; public class main5 { /** * @param args * @throws LDAPException */ // Create the configuration to use for the server. InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=ilex-si,dc=eu"); config.addAdditionalBindCredentials("cn=Directory Manager", "password"); // Create the directory server instance, populate it with data from the // "test-data.ldif" file, and start listening for client connections. InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config); ds.importFromLDIF(true, "data.ldif"); ds.startListening(); // Get a client connection to the server and use it to perform various // operations. LDAPConnection conn = ds.getConnection(); SearchResultEntry entry = conn.getEntry("dc=ilex-si,dc=eu"); // Do more stuff here.... try { response = br.readLine(); e.printStackTrace(); } // Disconnect from the server and cause the server to shut down. conn.close(); ds.shutDown(true); } }
You need to login to post a comment.
