如何在 java(外部安全模块)中使用 microstrategy SDK 创建用户
How to create a user using microstrategy SDK in java (External Security Module)
我的目标是使用 Microstrategy SDK 创建用户并为用户分配过滤器和组。
我有一个来自 SDK 的 java class CreateUser 和 SSOESM。我是否必须创建创建用户 class 的插件并将其部署在 microstrategy intelligence server.
public class CreateUser {
public static WebIServerSession sessionInfo;
public static final String loginName = "NewUser";
public static final String password= "";
public static final String fullName= "New User";
public static final String description="New User Created Programattically";
/* The following information is required to login and manipulate the User management API */
/* iServerName is the IServer we are connecting to */
public static final String iServerName = "localhost";
/* projectName is the project name we are connecting to */
public static final String projectName = "";
/* loginName is the user name we use to login the project */
public static final String adminLoginName = "administrator";
/* loginPasswd is the password we use to login the project */
public static final String adminLoginPasswd = "";
public static void main(String[] args) {
sessionInfo = getServerSession(iServerName, projectName, adminLoginName, adminLoginPasswd);
UserBean user = null;
try {
//Instantiate a new user
user = (UserBean)BeanFactory.getInstance().newBean("UserBean");
user.setSessionInfo(sessionInfo);
user.InitAsNew();
//Fetch properties for the user
WebUser ua = (WebUser) user.getUserEntityObject();
WebStandardLoginInfo loginInfo = ua.getStandardLoginInfo();
//Set basic user information
ua.setLoginName(loginName);
ua.setFullName(fullName);
user.getObjectInfo().setDescription(description);
loginInfo.setPassword(password);
//Set other properties
Calendar cal = Calendar.getInstance();
cal.set(2012, 11, 21);
Date d = cal.getTime();
loginInfo.setPasswordExpirationDate(d); //Password expires on November 21, 2012
loginInfo.setPasswordExpirationFrequency(90); //90 days to expire
loginInfo.setPasswordExpiresAutomatically(true); //If set to false, password never expires
loginInfo.setStandardAuthAllowed(true); //The user can log in using standard auth
user.save();
} catch (WebBeanException ex) {
System.out.println("Error creating a user: " + ex.getMessage());
}
}
public static WebIServerSession getServerSession(String serverName, String Project, String loginName, String password) {
WebIServerSession sessionInfo = null;
try {
WebObjectsFactory woFact = WebObjectsFactory.getInstance();
sessionInfo = woFact.getIServerSession();
sessionInfo.setServerName(serverName);
sessionInfo.setProjectName(Project);
sessionInfo.setLogin(loginName);
sessionInfo.setPassword(password);
sessionInfo.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
//Create a new session
sessionInfo.getSessionID();
} catch (WebObjectsException ex) {
System.out.println("Error creating a sesion");
}
return sessionInfo;
}
}
我的目标是当用户尝试登录时,应该使用 sdk classes 即时创建用户。
我必须创建一个插件并将插件配置为使用您创建的 java class 作为 ESM。
话虽如此,了解您正在执行的操作非常昂贵很重要。如果您尝试提供快速的 SSO 体验,它们可能会降低用户体验。根据您拥有的实现,创建一个自定义任务可能会更好,该任务可以在用户通过第三方应用程序进行身份验证时触发。此任务可以执行您描述的所有操作,然后 return 一个会话状态。可用于与 MicroStrategy Web 的任何后续连接。
我的目标是使用 Microstrategy SDK 创建用户并为用户分配过滤器和组。
我有一个来自 SDK 的 java class CreateUser 和 SSOESM。我是否必须创建创建用户 class 的插件并将其部署在 microstrategy intelligence server.
public class CreateUser { public static WebIServerSession sessionInfo; public static final String loginName = "NewUser"; public static final String password= ""; public static final String fullName= "New User"; public static final String description="New User Created Programattically"; /* The following information is required to login and manipulate the User management API */ /* iServerName is the IServer we are connecting to */ public static final String iServerName = "localhost"; /* projectName is the project name we are connecting to */ public static final String projectName = ""; /* loginName is the user name we use to login the project */ public static final String adminLoginName = "administrator"; /* loginPasswd is the password we use to login the project */ public static final String adminLoginPasswd = ""; public static void main(String[] args) { sessionInfo = getServerSession(iServerName, projectName, adminLoginName, adminLoginPasswd); UserBean user = null; try { //Instantiate a new user user = (UserBean)BeanFactory.getInstance().newBean("UserBean"); user.setSessionInfo(sessionInfo); user.InitAsNew(); //Fetch properties for the user WebUser ua = (WebUser) user.getUserEntityObject(); WebStandardLoginInfo loginInfo = ua.getStandardLoginInfo(); //Set basic user information ua.setLoginName(loginName); ua.setFullName(fullName); user.getObjectInfo().setDescription(description); loginInfo.setPassword(password); //Set other properties Calendar cal = Calendar.getInstance(); cal.set(2012, 11, 21); Date d = cal.getTime(); loginInfo.setPasswordExpirationDate(d); //Password expires on November 21, 2012 loginInfo.setPasswordExpirationFrequency(90); //90 days to expire loginInfo.setPasswordExpiresAutomatically(true); //If set to false, password never expires loginInfo.setStandardAuthAllowed(true); //The user can log in using standard auth user.save(); } catch (WebBeanException ex) { System.out.println("Error creating a user: " + ex.getMessage()); } } public static WebIServerSession getServerSession(String serverName, String Project, String loginName, String password) { WebIServerSession sessionInfo = null; try { WebObjectsFactory woFact = WebObjectsFactory.getInstance(); sessionInfo = woFact.getIServerSession(); sessionInfo.setServerName(serverName); sessionInfo.setProjectName(Project); sessionInfo.setLogin(loginName); sessionInfo.setPassword(password); sessionInfo.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp); //Create a new session sessionInfo.getSessionID(); } catch (WebObjectsException ex) { System.out.println("Error creating a sesion"); } return sessionInfo; } }
我的目标是当用户尝试登录时,应该使用 sdk classes 即时创建用户。
我必须创建一个插件并将插件配置为使用您创建的 java class 作为 ESM。
话虽如此,了解您正在执行的操作非常昂贵很重要。如果您尝试提供快速的 SSO 体验,它们可能会降低用户体验。根据您拥有的实现,创建一个自定义任务可能会更好,该任务可以在用户通过第三方应用程序进行身份验证时触发。此任务可以执行您描述的所有操作,然后 return 一个会话状态。可用于与 MicroStrategy Web 的任何后续连接。