我也是刚解决的!下面是个添加用户的例子
具体的你可以看看我也有个帖子就在本页
import java.util.*;
import javax.management.*;
import weblogic.management.*;
import weblogic.security.providers.authentication.*;
import weblogic.management.security.authentication.AuthenticationProviderMBean;
import weblogic.management.security.authentication.*;
public class test2
{
public static void main(String[] args )
{
MBeanHome adminHome;
String url = "t3://127.0.0.1:7001" ;
adminHome = (MBeanHome)Helper.getAdminMBeanHome("username","password",url);
AuthenticationProviderMBean[] providers = adminHome.getActiveDomain().getSecurityConfiguration().findDefaultRealm().getAuthenticationProviders();
for (int i=0; providers != null && i <providers.length; i++)
{
if (providers[i] instanceof UserEditorMBean)
{
UserEditorMBean editor = (UserEditorMBean)providers[i];
try
{
editor.createUser("username","password","description");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
}
}
|