users@glassfish.java.net

Programmatically changing passwords on GlassFish

From: <glassfish_at_javadesktop.org>
Date: Sat, 06 Dec 2008 13:17:57 PST

I am trying to change the password to users programmatically. I tried working with
this code snipplet:

javax.management.MBeanServer mbs = (javax.management.MBeanServer) javax.management.MBeanServerFactory.findMBeanServer(null).iterator().next();
javax.management.ObjectName on = new javax.management.ObjectName("com.sun.appserv:type=auth-realm,name=file,config=server-config,category=config");
Object o = mbs.invoke(on, "addUser", new Object[]{"username", "password", new String[]{"group1", "group2"}},
            new String[]{"java.lang.String","java.lang.String", "[Ljava.lang.String;"});
                
String users[] = (String[]) mbs.invoke(on, "getUserNames", new Object[0], new String[0]);
     for(String s : users) {
           System.out.println(s);
}

I an not sure how to connect to the server. Any help would be appreciated.
[Message sent by forum member 'blee1995' (blee1995)]

http://forums.java.net/jive/thread.jspa?messageID=320465