import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
import com.novell.service.ndssdk.jndi.ldap.ext.ReceiveAllUpdatesRequest;
public class ReceiveAllUpdates {
public static void main(String[] args) {
if (args.length != 6) {
usage();
}
String hostURL = args[0];
String loginDN = args[1];
String passWord = args[2];
String partitionDN = args[3];
String toServerDN = args[4];
String fromServerDN = args[5];
try {
Hashtable env = new Hashtable(5, 0.75f);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, hostURL);
env.put(Context.SECURITY_AUTHENTICATION, "simple" );
env.put(Context.SECURITY_PRINCIPAL, loginDN );
env.put(Context.SECURITY_CREDENTIALS, passWord );
LdapContext ctx = new InitialLdapContext(env, null);
ReceiveAllUpdatesRequest reqs = new ReceiveAllUpdatesRequest(
partitionDN, toServerDN, fromServerDN );
ctx.extendedOperation( reqs );
System.out.println("\n\tReceiveAllUpdates operation succeeded.");
}
catch (NamingException e) {
System.err.println("\n\tReceiveAllUpdates operation failed.");
e.printStackTrace();
}
finally {
System.exit(0);
}
}
public static void usage() {
System.err.println("\n Usage : java ReceiveAllUpdates <host URL>"
+ " <login dn> <password>\n <partition dn> <to-server dn> "
+ " <from-server dn>");
System.err.println("\n Example: java ReceiveAllUpdates"
+ " ldap://Acme.com:389 cn=admin,o=Acme secret\n"
+ " ou=sales,o=Acme cn=myServer1,o=Acme"
+ " cn=myServer2,o=Acme");
System.exit(1);
}
}