MicroStrategy ONE
Creating a Group
A user can be assigned to one or more groups. A group, in turn, can belong to one or more groups. When you create a new group, you need to provide some or all of the following information:
-
General
Name and description of this group.
-
Authentication
Distinguished name of the LDAP group to which members of this MicroStrategy group are linked for authentication, if you are using LDAP authentication.
-
Project Access
Projects for which users in this group have access privileges.
-
Security Filter
Security filters to be applied to this group.
-
Groups
Group or groups to which this group belongs.
-
Members
Users who belong to this group.
The sample code below illustrates how to create a new group, assign it a name, set the session state, and save the new group.
/**
* MicroStrategy SDK Sample
*
* Copyright © 2006 MicroStrategy Incorporated. All Rights Reserved.
*
* MICROSTRATEGY MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
* SUITABILITY OF THIS SAMPLE CODE, EITHER EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. MICROSTRATEGY SHALL NOT
* BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
* MODIFYING OR DISTRIBUTING THIS SAMPLE CODE OR ITS DERIVATIVES.
*
*
*/
package com.microstrategy.sdk.samples.usermanagement;
import com.microstrategy.web.beans.BeanFactory;
import com.microstrategy.web.beans.UserGroupBean;
import com.microstrategy.web.beans.WebBeanException;
import com.microstrategy.web.objects.WebIServerSession;
import com.microstrategy.web.objects.WebObjectsException;
import com.microstrategy.web.objects.WebObjectsFactory;
import com.microstrategy.webapi.EnumDSSXMLApplicationType;
public class CreateGroup {
public static WebIServerSession sessionInfo;
public static final String groupName = "NewGroup";
/* 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);
UserGroupBean group = null;
try {
//Create new group, set session, assign a name
group =(UserGroupBean) BeanFactory.getInstance().newBean("UserGroupBean");
group.setSessionInfo(sessionInfo);
group.InitAsNew();
group.getUserEntityObject().setFullName(groupName);
//Save the group
group.save();
} catch (WebBeanException ex) {
System.out.println("Error creating group: " + 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 session");
}
return sessionInfo;
}
}