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.TriggerBackgroundProcessRequest;
public class TriggerBackgroundProcess {
public static void main(String[] args) {
if( args.length != 4 ) {
usage();
}
String hostURL = args[0];
String loginDN = args[1];
String passWord = args[2];
int processID = Integer.parseInt(args[3]);
try {
String backgroundProcess;
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);
TriggerBackgroundProcessRequest reqs =
new TriggerBackgroundProcessRequest( processID );
ctx.extendedOperation(reqs);
System.out.println("\n\tBackground process" +
reqs.getBackgroundProcessName() + "is scheduled.");
}
catch(NamingException e) {
System.err.println("\n\tBackground process could not"
+" be scheduled.");
e.printStackTrace();
}
finally{
System.exit(0);
}
}
public static void usage() {
System.out.println("\n Usage : java TriggerBackgroundProcess "
+ " <host URL> <login dn> <password>"
+ "\n <background trigger type>");
System.out.println("\n Example: java TriggerBackgroundProcess"
+ " ldap://Acme.com:389 cn=admin,o=Acme "
+ "\n secret 1\n"
+ "\n <background trigger type>: 1 - back linker"
+ "\n 2 - janitor"
+ "\n 3 - limber"
+ "\n 4 - skulker"
+ "\n 5 - schema sync"
+ "\n 6 - partition purge");
System.exit(1);
}
}