如何在java中使用microstrategy SDK创建用户(外部安全模块)

时间:2016-03-03 20:52:09

标签: microstrategy

我的目标是使用microstrategy SDK创建用户,并为用户分配过滤器和组。

  1. 我有一个java类CreateUser&来自SDK的SSOESM。我是否必须创建create user类的插件并将其部署在microstrategy Intelligence服务器中。

    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;
        }
    }
    
  2. 我的目标是当用户尝试登录时,应该使用sdk类动态创建用户。

1 个答案:

答案 0 :(得分:1)

我必须创建一个插件并配置插件以使用您作为ESM创建的java类。

https://lw.microstrategy.com/msdz/MSDZ_World2015/docs/projects/WebSDK/output/HTML5/Content/topics/esm/specifying_the_custom_esm_to_use.htm

有了这个说,了解你正在执行的行动非常昂贵很重要。如果您尝试提供快速的SSO体验,它们可能会降低用户体验。根据您的实现,最好创建一个自定义任务,当用户使用第三方应用程序进行身份验证时,可以触发该任务。此任务可以执行您描述的所有操作,然后返回会话状态。可以在任何后续MicroStrategy Web连接中使用。