Here's the code (snippets) I wrote to add users remotely via JMX:
/*
* Connect the server probe
*/
try {
localInstanceProbe = new
JmxServerProbe("hostname", 9999);
} catch (IOException ioex) {
System.err.println("Error connecting to JMX
agent!");
ioex.printStackTrace();
System.exit(3);
} catch (InterruptedException iex) {
iex.printStackTrace();
System.exit(1);
} catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
}
// check if mailbox exists
try {
String mailbox = emailAcct == null || emailAcct.length()
< 1 ? (email == null
|| email.length() < 1 ? mb : email)
: emailAcct;
String password = emailPass == null || emailPass.length()
< 1 ? nmePass
: emailPass;
if (caller.checkIfMailboxExists(mailbox)) {
// reset password
caller.getLocalInstanceProbe().setPassword(mailbox, password);
}
else {
// create new mailbox
String domain =
mailbox.substring(mailbox.indexOf('@') + 1,
mailbox.length());
Boolean domainExists = false;
try {
domainExists =
caller.checkIfDomainExists(domain);
}
catch (NullPointerException npex) {
// This is thrown by
checkIfDomainExists because instead of
// returning a reference to an empty
array,
// JmxServerProbe.listDomains() returns
a null pointer
domainExists = false;
}
if (!domainExists) {
// if domain doesn't exist, create it
caller.getLocalInstanceProbe().addDomain(domain);
}
caller.getLocalInstanceProbe().addUser(mailbox,
password);
}
} catch (Exception ex) {
ex.printStackTrace();
}
On 7/18/2013 2:46 AM, Riley Scott wrote:
Hi,
We have a James 3 server running in our test lab. I need to add users remotely.
I need to create a Java app that will remotely connect to the James 3 server
and add users via JMX. Is this possible with JMX? If so, can you point me to
code samples / docs? Thanks.
--
Joshua M. Armstrong
Software Engineer
Centurion, Inc.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]